<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

************************************************************************
*                                                                      *
\section[OccurAnal]{Occurrence analysis pass}
*                                                                      *
************************************************************************

The occurrence analyser re-typechecks a core expression, returning a new
core expression with (hopefully) improved usage information.
-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-pragma">{-# LANGUAGE CPP, BangPatterns, MultiWayIf, ViewPatterns  #-}</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-17"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.OccurAnal</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occurAnalysePgm"><span class="hs-identifier">occurAnalysePgm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occurAnalyseExpr"><span class="hs-identifier">occurAnalyseExpr</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsTrivial"><span class="hs-identifier">exprIsTrivial</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#isDefaultAlt"><span class="hs-identifier">isDefaultAlt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#isExpandableApp"><span class="hs-identifier">isExpandableApp</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>                          </span><span class="annot"><a href="GHC.Core.Utils.html#stripTicksTopE"><span class="hs-identifier">stripTicksTopE</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier">mkTicks</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html"><span class="hs-identifier">GHC.Core.Opt.Arity</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier">joinRhsArity</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier">Module</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html"><span class="hs-identifier">GHC.Core.TyCo.FVs</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfMCo"><span class="hs-identifier">tyCoVarsOfMCo</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html"><span class="hs-identifier">GHC.Types.Demand</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#argOneShots"><span class="hs-identifier">argOneShots</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#argsOneShots"><span class="hs-identifier">argsOneShots</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html"><span class="hs-identifier">GHC.Data.Graph.Directed</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#SCC"><span class="hs-identifier">SCC</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier">Node</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesUniq"><span class="hs-identifier">stronglyConnCompFromEdgedVerticesUniq</span></a></span><span>
</span><span id="line-42"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesUniqR"><span class="hs-identifier">stronglyConnCompFromEdgedVerticesUniqR</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier">runRWKey</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier">isJust</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
    occurAnalysePgm, occurAnalyseExpr
*                                                                      *
************************************************************************

Here's the externally-callable interface:
-}</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occurAnalysePgm"><span class="hs-identifier hs-type">occurAnalysePgm</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span>         </span><span class="hs-comment">-- Used only in debug output</span><span>
</span><span id="line-63"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>         </span><span class="hs-comment">-- Active unfoldings</span><span>
</span><span id="line-64"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Activation"><span class="hs-identifier hs-type">Activation</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Active rules</span><span>
</span><span id="line-65"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-66"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-67"></span><span id="occurAnalysePgm"><span class="annot"><span class="annottext">occurAnalysePgm :: Module
-&gt; (CoreBndr -&gt; Bool)
-&gt; (Activation -&gt; Bool)
-&gt; [CoreRule]
-&gt; CoreProgram
-&gt; CoreProgram
</span><a href="GHC.Core.Opt.OccurAnal.html#occurAnalysePgm"><span class="hs-identifier hs-var hs-var">occurAnalysePgm</span></a></span></span><span> </span><span id="local-6989586621680867277"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680867277"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span id="local-6989586621680867276"><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="#local-6989586621680867276"><span class="hs-identifier hs-var">active_unf</span></a></span></span><span> </span><span id="local-6989586621680867275"><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="#local-6989586621680867275"><span class="hs-identifier hs-var">active_rule</span></a></span></span><span> </span><span id="local-6989586621680867274"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680867274"><span class="hs-identifier hs-var">imp_rules</span></a></span></span><span> </span><span id="local-6989586621680867273"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867273"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-68"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isEmptyDetails"><span class="hs-identifier hs-var">isEmptyDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867271"><span class="hs-identifier hs-var">final_usage</span></a></span><span>
</span><span id="line-69"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867270"><span class="hs-identifier hs-var">occ_anald_binds</span></a></span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- See Note [Glomming]</span><span>
</span><span id="line-72"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">hang</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Glomming in&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">this_mod</span><span> </span><span class="hs-operator">&lt;&gt;</span><span> </span><span class="hs-identifier">colon</span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>                   </span><span class="hs-number">2</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">final_usage</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>    </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867262"><span class="hs-identifier hs-var">occ_anald_glommed_binds</span></a></span><span>
</span><span id="line-75"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-76"></span><span>    </span><span id="local-6989586621680867261"><span class="annot"><span class="annottext">init_env :: OccEnv
</span><a href="#local-6989586621680867261"><span class="hs-identifier hs-var hs-var">init_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#initOccEnv"><span class="hs-identifier hs-var">initOccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_rule_act :: Activation -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_rule_act"><span class="hs-identifier hs-var">occ_rule_act</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="#local-6989586621680867275"><span class="hs-identifier hs-var">active_rule</span></a></span><span>
</span><span id="line-77"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_unf_act :: CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_unf_act"><span class="hs-identifier hs-var">occ_unf_act</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="#local-6989586621680867276"><span class="hs-identifier hs-var">active_unf</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867271"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867271"><span class="hs-identifier hs-var">final_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867270"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867270"><span class="hs-identifier hs-var">occ_anald_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreProgram -&gt; (UsageDetails, CoreProgram)
</span><a href="#local-6989586621680867257"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867261"><span class="hs-identifier hs-var">init_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867273"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-80"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867262"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867262"><span class="hs-identifier hs-var">occ_anald_glommed_binds</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; [(CoreBndr, CoreExpr)]
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRecBind"><span class="hs-identifier hs-var">occAnalRecBind</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867261"><span class="hs-identifier hs-var">init_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span>
</span><span id="line-81"></span><span>                                                    </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867254"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span><span>
</span><span id="line-82"></span><span>                                                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreProgram -&gt; [(CoreBndr, CoreExpr)]
forall b. [Bind b] -&gt; [(b, Expr b)]
</span><a href="GHC.Core.html#flattenBinds"><span class="hs-identifier hs-var">flattenBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867273"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>                                                    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867252"><span class="hs-identifier hs-var">initial_uds</span></a></span><span>
</span><span id="line-84"></span><span>          </span><span class="hs-comment">-- It's crucial to re-analyse the glommed-together bindings</span><span>
</span><span id="line-85"></span><span>          </span><span class="hs-comment">-- so that we establish the right loop breakers. Otherwise</span><span>
</span><span id="line-86"></span><span>          </span><span class="hs-comment">-- we can easily create an infinite loop (#9583 is an example)</span><span>
</span><span id="line-87"></span><span>          </span><span class="hs-comment">--</span><span>
</span><span id="line-88"></span><span>          </span><span class="hs-comment">-- Also crucial to re-analyse the /original/ bindings</span><span>
</span><span id="line-89"></span><span>          </span><span class="hs-comment">-- in case the first pass accidentally discarded as dead code</span><span>
</span><span id="line-90"></span><span>          </span><span class="hs-comment">-- a binding that was actually needed (albeit before its</span><span>
</span><span id="line-91"></span><span>          </span><span class="hs-comment">-- definition site).  #17724 threw this up.</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span>    </span><span id="local-6989586621680867252"><span class="annot"><span class="annottext">initial_uds :: UsageDetails
</span><a href="#local-6989586621680867252"><span class="hs-identifier hs-var hs-var">initial_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var">addManyOccs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule] -&gt; VarSet
</span><a href="GHC.Core.FVs.html#rulesFreeVars"><span class="hs-identifier hs-var">rulesFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680867274"><span class="hs-identifier hs-var">imp_rules</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span>    </span><span class="hs-comment">-- The RULES declarations keep things alive!</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span>    </span><span class="hs-comment">-- Note [Preventing loops due to imported functions rules]</span><span>
</span><span id="line-97"></span><span>    </span><span id="local-6989586621680867254"><span class="annot"><span class="annottext">imp_rule_edges :: ImpRuleEdges
</span><a href="#local-6989586621680867254"><span class="hs-identifier hs-var hs-var">imp_rule_edges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ImpRuleEdges -&gt; ImpRuleEdges -&gt; ImpRuleEdges)
-&gt; ImpRuleEdges -&gt; [ImpRuleEdges] -&gt; ImpRuleEdges
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet -&gt; VarSet)
-&gt; ImpRuleEdges -&gt; ImpRuleEdges -&gt; ImpRuleEdges
forall a. (a -&gt; a -&gt; a) -&gt; VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv_C"><span class="hs-identifier hs-var">plusVarEnv_C</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-98"></span><span>                            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; VarSet) -&gt; VarEnv CoreBndr -&gt; ImpRuleEdges
forall a b. (a -&gt; b) -&gt; VarEnv a -&gt; VarEnv b
</span><a href="GHC.Types.Var.Env.html#mapVarEnv"><span class="hs-identifier hs-var">mapVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; CoreBndr -&gt; VarSet
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867241"><span class="hs-identifier hs-var">maps_to</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(VarEnv CoreBndr -&gt; ImpRuleEdges)
-&gt; VarEnv CoreBndr -&gt; ImpRuleEdges
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-99"></span><span>                                </span><span class="annot"><span class="annottext">VarSet -&gt; VarEnv CoreBndr
forall a. UniqSet a -&gt; UniqFM a a
</span><a href="GHC.Types.Unique.Set.html#getUniqSet"><span class="hs-identifier hs-var">getUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeIds"><span class="hs-identifier hs-var">exprFreeIds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867238"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [CoreBndr] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; [CoreBndr]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var hs-var">ru_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680867235"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680867274"><span class="hs-identifier hs-var">imp_rules</span></a></span><span>
</span><span id="line-101"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule -&gt; Bool
</span><a href="GHC.Core.html#isBuiltinRule"><span class="hs-identifier hs-var">isBuiltinRule</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Plugin rules]</span><span>
</span><span id="line-102"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680867241"><span class="annot"><span class="annottext">maps_to :: VarSet
</span><a href="#local-6989586621680867241"><span class="hs-identifier hs-var hs-var">maps_to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeIds"><span class="hs-identifier hs-var">exprFreeIds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule -&gt; CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var hs-var">ru_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span>                                             </span><span class="annot"><span class="annottext">VarSet -&gt; [CoreBndr] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; [CoreBndr]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var hs-var">ru_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span><span>
</span><span id="line-104"></span><span>                            </span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867238"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867238"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var hs-var">ru_args</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867235"><span class="hs-identifier hs-var">imp_rule</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span>    </span><span class="annot"><a href="#local-6989586621680867257"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>    </span><span id="local-6989586621680867257"><span class="annot"><span class="annottext">go :: OccEnv -&gt; CoreProgram -&gt; (UsageDetails, CoreProgram)
</span><a href="#local-6989586621680867257"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-108"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867252"><span class="hs-identifier hs-var">initial_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>    </span><span class="annot"><a href="#local-6989586621680867257"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867230"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867230"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867229"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680867229"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867228"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867228"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867227"><span class="hs-identifier hs-var">final_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867226"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867225"><span class="hs-identifier hs-var">binds'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-112"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621680867224"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867224"><span class="hs-identifier hs-var">bs_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867225"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867225"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreProgram -&gt; (UsageDetails, CoreProgram)
</span><a href="#local-6989586621680867257"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867230"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867228"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-113"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621680867227"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867227"><span class="hs-identifier hs-var">final_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867226"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867226"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; CoreBind
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalBind"><span class="hs-identifier hs-var">occAnalBind</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867230"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867254"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680867229"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-114"></span><span>                                              </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867224"><span class="hs-identifier hs-var">bs_usage</span></a></span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occurAnalyseExpr"><span class="hs-identifier hs-type">occurAnalyseExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-117"></span><span class="hs-comment">-- Do occurrence analysis, and discard occurrence info returned</span><span>
</span><span id="line-118"></span><span id="occurAnalyseExpr"><span class="annot"><span class="annottext">occurAnalyseExpr :: CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#occurAnalyseExpr"><span class="hs-identifier hs-var hs-var">occurAnalyseExpr</span></a></span></span><span> </span><span id="local-6989586621680867222"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867222"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails, CoreExpr) -&gt; CoreExpr
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#initOccEnv"><span class="hs-identifier hs-var">initOccEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867222"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-comment">{- Note [Plugin rules]
~~~~~~~~~~~~~~~~~~~~~~
Conal Elliott (#11651) built a GHC plugin that added some
BuiltinRules (for imported Ids) to the mg_rules field of ModGuts, to
do some domain-specific transformations that could not be expressed
with an ordinary pattern-matching CoreRule.  But then we can't extract
the dependencies (in imp_rule_edges) from ru_rhs etc, because a
BuiltinRule doesn't have any of that stuff.

So we simply assume that BuiltinRules have no dependencies, and filter
them out from the imp_rule_edges comprehension.
-}</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Bindings
*                                                                      *
************************************************************************

Note [Recursive bindings: the grand plan]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we come across a binding group
  Rec { x1 = r1; ...; xn = rn }
we treat it like this (occAnalRecBind):

1. Occurrence-analyse each right hand side, and build a
   &quot;Details&quot; for each binding to capture the results.

   Wrap the details in a Node (details, node-id, dep-node-ids),
   where node-id is just the unique of the binder, and
   dep-node-ids lists all binders on which this binding depends.
   We'll call these the &quot;scope edges&quot;.
   See Note [Forming the Rec groups].

   All this is done by makeNode.

2. Do SCC-analysis on these Nodes.  Each SCC will become a new Rec or
   NonRec.  The key property is that every free variable of a binding
   is accounted for by the scope edges, so that when we are done
   everything is still in scope.

3. For each Cyclic SCC of the scope-edge SCC-analysis in (2), we
   identify suitable loop-breakers to ensure that inlining terminates.
   This is done by occAnalRec.

4. To do so we form a new set of Nodes, with the same details, but
   different edges, the &quot;loop-breaker nodes&quot;. The loop-breaker nodes
   have both more and fewer dependencies than the scope edges
   (see Note [Choosing loop breakers])

   More edges: if f calls g, and g has an active rule that mentions h
               then we add an edge from f -&gt; h

   Fewer edges: we only include dependencies on active rules, on rule
                RHSs (not LHSs) and if there is an INLINE pragma only
                on the stable unfolding (and vice versa).  The scope
                edges must be much more inclusive.

5.  The &quot;weak fvs&quot; of a node are, by definition:
       the scope fvs - the loop-breaker fvs
    See Note [Weak loop breakers], and the nd_weak field of Details

6.  Having formed the loop-breaker nodes

Note [Dead code]
~~~~~~~~~~~~~~~~
Dropping dead code for a cyclic Strongly Connected Component is done
in a very simple way:

        the entire SCC is dropped if none of its binders are mentioned
        in the body; otherwise the whole thing is kept.

The key observation is that dead code elimination happens after
dependency analysis: so 'occAnalBind' processes SCCs instead of the
original term's binding groups.

Thus 'occAnalBind' does indeed drop 'f' in an example like

        letrec f = ...g...
               g = ...(...g...)...
        in
           ...g...

when 'g' no longer uses 'f' at all (eg 'f' does not occur in a RULE in
'g'). 'occAnalBind' first consumes 'CyclicSCC g' and then it consumes
'AcyclicSCC f', where 'body_usage' won't contain 'f'.

------------------------------------------------------------
Note [Forming Rec groups]
~~~~~~~~~~~~~~~~~~~~~~~~~
We put bindings {f = ef; g = eg } in a Rec group if &quot;f uses g&quot;
and &quot;g uses f&quot;, no matter how indirectly.  We do a SCC analysis
with an edge f -&gt; g if &quot;f uses g&quot;.

More precisely, &quot;f uses g&quot; iff g should be in scope wherever f is.
That is, g is free in:
  a) the rhs 'ef'
  b) or the RHS of a rule for f (Note [Rules are extra RHSs])
  c) or the LHS or a rule for f (Note [Rule dependency info])

These conditions apply regardless of the activation of the RULE (eg it might be
inactive in this phase but become active later).  Once a Rec is broken up
it can never be put back together, so we must be conservative.

The principle is that, regardless of rule firings, every variable is
always in scope.

  * Note [Rules are extra RHSs]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    A RULE for 'f' is like an extra RHS for 'f'. That way the &quot;parent&quot;
    keeps the specialised &quot;children&quot; alive.  If the parent dies
    (because it isn't referenced any more), then the children will die
    too (unless they are already referenced directly).

    To that end, we build a Rec group for each cyclic strongly
    connected component,
        *treating f's rules as extra RHSs for 'f'*.
    More concretely, the SCC analysis runs on a graph with an edge
    from f -&gt; g iff g is mentioned in
        (a) f's rhs
        (b) f's RULES
    These are rec_edges.

    Under (b) we include variables free in *either* LHS *or* RHS of
    the rule.  The former might seems silly, but see Note [Rule
    dependency info].  So in Example [eftInt], eftInt and eftIntFB
    will be put in the same Rec, even though their 'main' RHSs are
    both non-recursive.

  * Note [Rule dependency info]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The VarSet in a RuleInfo is used for dependency analysis in the
    occurrence analyser.  We must track free vars in *both* lhs and rhs.
    Hence use of idRuleVars, rather than idRuleRhsVars in occAnalBind.
    Why both? Consider
        x = y
        RULE f x = v+4
    Then if we substitute y for x, we'd better do so in the
    rule's LHS too, so we'd better ensure the RULE appears to mention 'x'
    as well as 'v'

  * Note [Rules are visible in their own rec group]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    We want the rules for 'f' to be visible in f's right-hand side.
    And we'd like them to be visible in other functions in f's Rec
    group.  E.g. in Note [Specialisation rules] we want f' rule
    to be visible in both f's RHS, and fs's RHS.

    This means that we must simplify the RULEs first, before looking
    at any of the definitions.  This is done by Simplify.simplRecBind,
    when it calls addLetIdInfo.

------------------------------------------------------------
Note [Choosing loop breakers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loop breaking is surprisingly subtle.  First read the section 4 of
&quot;Secrets of the GHC inliner&quot;.  This describes our basic plan.
We avoid infinite inlinings by choosing loop breakers, and
ensuring that a loop breaker cuts each loop.

See also Note [Inlining and hs-boot files] in GHC.Core.ToIface, which
deals with a closely related source of infinite loops.

Fundamentally, we do SCC analysis on a graph.  For each recursive
group we choose a loop breaker, delete all edges to that node,
re-analyse the SCC, and iterate.

But what is the graph?  NOT the same graph as was used for Note
[Forming Rec groups]!  In particular, a RULE is like an equation for
'f' that is *always* inlined if it is applicable.  We do *not* disable
rules for loop-breakers.  It's up to whoever makes the rules to make
sure that the rules themselves always terminate.  See Note [Rules for
recursive functions] in GHC.Core.Opt.Simplify

Hence, if
    f's RHS (or its INLINE template if it has one) mentions g, and
    g has a RULE that mentions h, and
    h has a RULE that mentions f

then we *must* choose f to be a loop breaker.  Example: see Note
[Specialisation rules].

In general, take the free variables of f's RHS, and augment it with
all the variables reachable by RULES from those starting points.  That
is the whole reason for computing rule_fv_env in occAnalBind.  (Of
course we only consider free vars that are also binders in this Rec
group.)  See also Note [Finding rule RHS free vars]

Note that when we compute this rule_fv_env, we only consider variables
free in the *RHS* of the rule, in contrast to the way we build the
Rec group in the first place (Note [Rule dependency info])

Note that if 'g' has RHS that mentions 'w', we should add w to
g's loop-breaker edges.  More concretely there is an edge from f -&gt; g
iff
        (a) g is mentioned in f's RHS `xor` f's INLINE rhs
            (see Note [Inline rules])
        (b) or h is mentioned in f's RHS, and
            g appears in the RHS of an active RULE of h
            or a transitive sequence of active rules starting with h

Why &quot;active rules&quot;?  See Note [Finding rule RHS free vars]

Note that in Example [eftInt], *neither* eftInt *nor* eftIntFB is
chosen as a loop breaker, because their RHSs don't mention each other.
And indeed both can be inlined safely.

Note again that the edges of the graph we use for computing loop breakers
are not the same as the edges we use for computing the Rec blocks.
That's why we compute

- rec_edges          for the Rec block analysis
- loop_breaker_nodes for the loop breaker analysis

  * Note [Finding rule RHS free vars]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Consider this real example from Data Parallel Haskell
         tagZero :: Array Int -&gt; Array Tag
         {-# INLINE [1] tagZeroes #-}
         tagZero xs = pmap (\x -&gt; fromBool (x==0)) xs

         {-# RULES &quot;tagZero&quot; [~1] forall xs n.
             pmap fromBool &lt;blah blah&gt; = tagZero xs #-}
    So tagZero's RHS mentions pmap, and pmap's RULE mentions tagZero.
    However, tagZero can only be inlined in phase 1 and later, while
    the RULE is only active *before* phase 1.  So there's no problem.

    To make this work, we look for the RHS free vars only for
    *active* rules. That's the reason for the occ_rule_act field
    of the OccEnv.

  * Note [Weak loop breakers]
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    There is a last nasty wrinkle.  Suppose we have

        Rec { f = f_rhs
              RULE f [] = g

              h = h_rhs
              g = h
              ...more...
        }

    Remember that we simplify the RULES before any RHS (see Note
    [Rules are visible in their own rec group] above).

    So we must *not* postInlineUnconditionally 'g', even though
    its RHS turns out to be trivial.  (I'm assuming that 'g' is
    not chosen as a loop breaker.)  Why not?  Because then we
    drop the binding for 'g', which leaves it out of scope in the
    RULE!

    Here's a somewhat different example of the same thing
        Rec { g = h
            ; h = ...f...
            ; f = f_rhs
              RULE f [] = g }
    Here the RULE is &quot;below&quot; g, but we *still* can't postInlineUnconditionally
    g, because the RULE for f is active throughout.  So the RHS of h
    might rewrite to     h = ...g...
    So g must remain in scope in the output program!

    We &quot;solve&quot; this by:

        Make g a &quot;weak&quot; loop breaker (OccInfo = IAmLoopBreaker True)
        iff g is a &quot;missing free variable&quot; of the Rec group

    A &quot;missing free variable&quot; x is one that is mentioned in an RHS or
    INLINE or RULE of a binding in the Rec group, but where the
    dependency on x may not show up in the loop_breaker_nodes (see
    note [Choosing loop breakers} above).

    A normal &quot;strong&quot; loop breaker has IAmLoopBreaker False.  So

                                    Inline  postInlineUnconditionally
   strong   IAmLoopBreaker False    no      no
   weak     IAmLoopBreaker True     yes     no
            other                   yes     yes

    The **sole** reason for this kind of loop breaker is so that
    postInlineUnconditionally does not fire.  Ugh.  (Typically it'll
    inline via the usual callSiteInline stuff, so it'll be dead in the
    next pass, so the main Ugh is the tiresome complication.)

Note [Rules for imported functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this
   f = /\a. B.g a
   RULE B.g Int = 1 + f Int
Note that
  * The RULE is for an imported function.
  * f is non-recursive
Now we
can get
   f Int --&gt; B.g Int      Inlining f
         --&gt; 1 + f Int    Firing RULE
and so the simplifier goes into an infinite loop. This
would not happen if the RULE was for a local function,
because we keep track of dependencies through rules.  But
that is pretty much impossible to do for imported Ids.  Suppose
f's definition had been
   f = /\a. C.h a
where (by some long and devious process), C.h eventually inlines to
B.g.  We could only spot such loops by exhaustively following
unfoldings of C.h etc, in case we reach B.g, and hence (via the RULE)
f.

Note that RULES for imported functions are important in practice; they
occur a lot in the libraries.

We regard this potential infinite loop as a *programmer* error.
It's up the programmer not to write silly rules like
     RULE f x = f x
and the example above is just a more complicated version.

Note [Preventing loops due to imported functions rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider:
  import GHC.Base (foldr)

  {-# RULES &quot;filterList&quot; forall p. foldr (filterFB (:) p) [] = filter p #-}
  filter p xs = build (\c n -&gt; foldr (filterFB c p) n xs)
  filterFB c p = ...

  f = filter p xs

Note that filter is not a loop-breaker, so what happens is:
  f =          filter p xs
    = {inline} build (\c n -&gt; foldr (filterFB c p) n xs)
    = {inline} foldr (filterFB (:) p) [] xs
    = {RULE}   filter p xs

We are in an infinite loop.

A more elaborate example (that I actually saw in practice when I went to
mark GHC.List.filter as INLINABLE) is as follows. Say I have this module:
  {-# LANGUAGE RankNTypes #-}
  module GHCList where

  import Prelude hiding (filter)
  import GHC.Base (build)

  {-# INLINABLE filter #-}
  filter :: (a -&gt; Bool) -&gt; [a] -&gt; [a]
  filter p [] = []
  filter p (x:xs) = if p x then x : filter p xs else filter p xs

  {-# NOINLINE [0] filterFB #-}
  filterFB :: (a -&gt; b -&gt; b) -&gt; (a -&gt; Bool) -&gt; a -&gt; b -&gt; b
  filterFB c p x r | p x       = x `c` r
                   | otherwise = r

  {-# RULES
  &quot;filter&quot;     [~1] forall p xs.  filter p xs = build (\c n -&gt; foldr
  (filterFB c p) n xs)
  &quot;filterList&quot; [1]  forall p.     foldr (filterFB (:) p) [] = filter p
   #-}

Then (because RULES are applied inside INLINABLE unfoldings, but inlinings
are not), the unfolding given to &quot;filter&quot; in the interface file will be:
  filter p []     = []
  filter p (x:xs) = if p x then x : build (\c n -&gt; foldr (filterFB c p) n xs)
                           else     build (\c n -&gt; foldr (filterFB c p) n xs

Note that because this unfolding does not mention &quot;filter&quot;, filter is not
marked as a strong loop breaker. Therefore at a use site in another module:
  filter p xs
    = {inline}
      case xs of []     -&gt; []
                 (x:xs) -&gt; if p x then x : build (\c n -&gt; foldr (filterFB c p) n xs)
                                  else     build (\c n -&gt; foldr (filterFB c p) n xs)

  build (\c n -&gt; foldr (filterFB c p) n xs)
    = {inline} foldr (filterFB (:) p) [] xs
    = {RULE}   filter p xs

And we are in an infinite loop again, except that this time the loop is producing an
infinitely large *term* (an unrolling of filter) and so the simplifier finally
dies with &quot;ticks exhausted&quot;

Because of this problem, we make a small change in the occurrence analyser
designed to mark functions like &quot;filter&quot; as strong loop breakers on the basis that:
  1. The RHS of filter mentions the local function &quot;filterFB&quot;
  2. We have a rule which mentions &quot;filterFB&quot; on the LHS and &quot;filter&quot; on the RHS

So for each RULE for an *imported* function we are going to add
dependency edges between the *local* FVS of the rule LHS and the
*local* FVS of the rule RHS. We don't do anything special for RULES on
local functions because the standard occurrence analysis stuff is
pretty good at getting loop-breakerness correct there.

It is important to note that even with this extra hack we aren't always going to get
things right. For example, it might be that the rule LHS mentions an imported Id,
and another module has a RULE that can rewrite that imported Id to one of our local
Ids.

Note [Specialising imported functions] (referred to from Specialise)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BUT for *automatically-generated* rules, the programmer can't be
responsible for the &quot;programmer error&quot; in Note [Rules for imported
functions].  In particular, consider specialising a recursive function
defined in another module.  If we specialise a recursive function B.g,
we get
         g_spec = .....(B.g Int).....
         RULE B.g Int = g_spec
Here, g_spec doesn't look recursive, but when the rule fires, it
becomes so.  And if B.g was mutually recursive, the loop might
not be as obvious as it is here.

To avoid this,
 * When specialising a function that is a loop breaker,
   give a NOINLINE pragma to the specialised function

Note [Glomming]
~~~~~~~~~~~~~~~
RULES for imported Ids can make something at the top refer to something at the bottom:
        f = \x -&gt; B.g (q x)
        h = \y -&gt; 3

        RULE:  B.g (q x) = h x

Applying this rule makes f refer to h, although f doesn't appear to
depend on h.  (And, as in Note [Rules for imported functions], the
dependency might be more indirect. For example, f might mention C.t
rather than B.g, where C.t eventually inlines to B.g.)

NOTICE that this cannot happen for rules whose head is a
locally-defined function, because we accurately track dependencies
through RULES.  It only happens for rules whose head is an imported
function (B.g in the example above).

Solution:
  - When simplifying, bring all top level identifiers into
    scope at the start, ignoring the Rec/NonRec structure, so
    that when 'h' pops up in f's rhs, we find it in the in-scope set
    (as the simplifier generally expects). This happens in simplTopBinds.

  - In the occurrence analyser, if there are any out-of-scope
    occurrences that pop out of the top, which will happen after
    firing the rule:      f = \x -&gt; h x
                          h = \y -&gt; 3
    then just glom all the bindings into a single Rec, so that
    the *next* iteration of the occurrence analyser will sort
    them all out.   This part happens in occurAnalysePgm.

------------------------------------------------------------
Note [Inline rules]
~~~~~~~~~~~~~~~~~~~
None of the above stuff about RULES applies to Inline Rules,
stored in a CoreUnfolding.  The unfolding, if any, is simplified
at the same time as the regular RHS of the function (ie *not* like
Note [Rules are visible in their own rec group]), so it should be
treated *exactly* like an extra RHS.

Or, rather, when computing loop-breaker edges,
  * If f has an INLINE pragma, and it is active, we treat the
    INLINE rhs as f's rhs
  * If it's inactive, we treat f as having no rhs
  * If it has no INLINE pragma, we look at f's actual rhs


There is a danger that we'll be sub-optimal if we see this
     f = ...f...
     [INLINE f = ..no f...]
where f is recursive, but the INLINE is not. This can just about
happen with a sufficiently odd set of rules; eg

        foo :: Int -&gt; Int
        {-# INLINE [1] foo #-}
        foo x = x+1

        bar :: Int -&gt; Int
        {-# INLINE [1] bar #-}
        bar x = foo x + 1

        {-# RULES &quot;foo&quot; [~1] forall x. foo x = bar x #-}

Here the RULE makes bar recursive; but it's INLINE pragma remains
non-recursive. It's tempting to then say that 'bar' should not be
a loop breaker, but an attempt to do so goes wrong in two ways:
   a) We may get
         $df = ...$cfoo...
         $cfoo = ...$df....
         [INLINE $cfoo = ...no-$df...]
      But we want $cfoo to depend on $df explicitly so that we
      put the bindings in the right order to inline $df in $cfoo
      and perhaps break the loop altogether.  (Maybe this
   b)


Example [eftInt]
~~~~~~~~~~~~~~~
Example (from GHC.Enum):

  eftInt :: Int# -&gt; Int# -&gt; [Int]
  eftInt x y = ...(non-recursive)...

  {-# INLINE [0] eftIntFB #-}
  eftIntFB :: (Int -&gt; r -&gt; r) -&gt; r -&gt; Int# -&gt; Int# -&gt; r
  eftIntFB c n x y = ...(non-recursive)...

  {-# RULES
  &quot;eftInt&quot;  [~1] forall x y. eftInt x y = build (\ c n -&gt; eftIntFB c n x y)
  &quot;eftIntList&quot;  [1] eftIntFB  (:) [] = eftInt
   #-}

Note [Specialisation rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this group, which is typical of what SpecConstr builds:

   fs a = ....f (C a)....
   f  x = ....f (C a)....
   {-# RULE f (C a) = fs a #-}

So 'f' and 'fs' are in the same Rec group (since f refers to fs via its RULE).

But watch out!  If 'fs' is not chosen as a loop breaker, we may get an infinite loop:
  - the RULE is applied in f's RHS (see Note [Self-recursive rules] in GHC.Core.Opt.Simplify
  - fs is inlined (say it's small)
  - now there's another opportunity to apply the RULE

This showed up when compiling Control.Concurrent.Chan.getChanContents.

------------------------------------------------------------
Note [Finding join points]
~~~~~~~~~~~~~~~~~~~~~~~~~~
It's the occurrence analyser's job to find bindings that we can turn into join
points, but it doesn't perform that transformation right away. Rather, it marks
the eligible bindings as part of their occurrence data, leaving it to the
simplifier (or to simpleOptPgm) to actually change the binder's 'IdDetails'.
The simplifier then eta-expands the RHS if needed and then updates the
occurrence sites. Dividing the work this way means that the occurrence analyser
still only takes one pass, yet one can always tell the difference between a
function call and a jump by looking at the occurrence (because the same pass
changes the 'IdDetails' and propagates the binders to their occurrence sites).

To track potential join points, we use the 'occ_tail' field of OccInfo. A value
of `AlwaysTailCalled n` indicates that every occurrence of the variable is a
tail call with `n` arguments (counting both value and type arguments). Otherwise
'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the
rest of 'OccInfo' until it goes on the binder.

Note [Join points and unfoldings/rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   let j2 y = blah
   let j x = j2 (x+x)
       {-# INLINE [2] j #-}
   in case e of { A -&gt; j 1; B -&gt; ...; C -&gt; j 2 }

Before j is inlined, we'll have occurrences of j2 in
both j's RHS and in its stable unfolding.  We want to discover
j2 as a join point.  So we must do the adjustRhsUsage thing
on j's RHS.  That's why we pass mb_join_arity to calcUnfolding.

Aame with rules. Suppose we have:

  let j :: Int -&gt; Int
      j y = 2 * y
  let k :: Int -&gt; Int -&gt; Int
      {-# RULES &quot;SPEC k 0&quot; k 0 y = j y #-}
      k x y = x + 2 * y
  in case e of { A -&gt; k 1 2; B -&gt; k 3 5; C -&gt; blah }

We identify k as a join point, and we want j to be a join point too.
Without the RULE it would be, and we don't want the RULE to mess it
up.  So provided the join-point arity of k matches the args of the
rule we can allow the tail-cal info from the RHS of the rule to
propagate.

* Wrinkle for Rec case. In the recursive case we don't know the
  join-point arity in advance, when calling occAnalUnfolding and
  occAnalRules.  (See makeNode.)  We don't want to pass Nothing,
  because then a recursive joinrec might lose its join-poin-hood
  when SpecConstr adds a RULE.  So we just make do with the
  *current* join-poin-hood, stored in the Id.

  In the non-recursive case things are simple: see occAnalNonRecBind

* Wrinkle for RULES.  Suppose the example was a bit different:
      let j :: Int -&gt; Int
          j y = 2 * y
          k :: Int -&gt; Int -&gt; Int
          {-# RULES &quot;SPEC k 0&quot; k 0 = j #-}
          k x y = x + 2 * y
      in ...
  If we eta-expanded the rule all woudl be well, but as it stands the
  one arg of the rule don't match the join-point arity of 2.

  Conceivably we could notice that a potential join point would have
  an &quot;undersaturated&quot; rule and account for it. This would mean we
  could make something that's been specialised a join point, for
  instance. But local bindings are rarely specialised, and being
  overly cautious about rules only costs us anything when, for some `j`:

  * Before specialisation, `j` has non-tail calls, so it can't be a join point.
  * During specialisation, `j` gets specialised and thus acquires rules.
  * Sometime afterward, the non-tail calls to `j` disappear (as dead code, say),
    and so now `j` *could* become a join point.

  This appears to be very rare in practice. TODO Perhaps we should gather
  statistics to be sure.

------------------------------------------------------------
Note [Adjusting right-hand sides]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There's a bit of a dance we need to do after analysing a lambda expression or
a right-hand side. In particular, we need to

  a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot
     lambda, or a non-recursive join point; and
  b) call 'markAllNonTail' *unless* the binding is for a join point.

Some examples, with how the free occurrences in e (assumed not to be a value
lambda) get marked:

                             inside lam    non-tail-called
  ------------------------------------------------------------
  let x = e                  No            Yes
  let f = \x -&gt; e            Yes           Yes
  let f = \x{OneShot} -&gt; e   No            Yes
  \x -&gt; e                    Yes           Yes
  join j x = e               No            No
  joinrec j x = e            Yes           No

There are a few other caveats; most importantly, if we're marking a binding as
'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so
that the effect cascades properly. Consequently, at the time the RHS is
analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must
return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once
join-point-hood has been decided.

Thus the overall sequence taking place in 'occAnalNonRecBind' and
'occAnalRecBind' is as follows:

  1. Call 'occAnalLamOrRhs' to find usage information for the RHS.
  2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make
     the binding a join point.
  3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when
     recursive.)

(In the recursive case, this logic is spread between 'makeNode' and
'occAnalRec'.)
-}</span><span>
</span><span id="line-766"></span><span>
</span><span id="line-767"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-768"></span><span class="hs-comment">--                 occAnalBind</span><span>
</span><span id="line-769"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-770"></span><span>
</span><span id="line-771"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalBind"><span class="hs-identifier hs-type">occAnalBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>           </span><span class="hs-comment">-- The incoming OccEnv</span><span>
</span><span id="line-772"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>
</span><span id="line-773"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-type">ImpRuleEdges</span></a></span><span>
</span><span id="line-774"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span>
</span><span id="line-775"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>             </span><span class="hs-comment">-- Usage details of scope</span><span>
</span><span id="line-776"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- Of the whole let(rec)</span><span>
</span><span id="line-777"></span><span>                </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-778"></span><span>
</span><span id="line-779"></span><span id="occAnalBind"><span class="annot"><span class="annottext">occAnalBind :: OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; CoreBind
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalBind"><span class="hs-identifier hs-var hs-var">occAnalBind</span></a></span></span><span> </span><span id="local-6989586621680867220"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867220"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867219"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867219"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680867218"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867218"><span class="hs-identifier hs-var">top_env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680867216"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867216"><span class="hs-identifier hs-var">binder</span></a></span></span><span> </span><span id="local-6989586621680867215"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867215"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867214"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867214"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span>
</span><span id="line-780"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; CoreBndr
-&gt; CoreExpr
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalNonRecBind"><span class="hs-identifier hs-var">occAnalNonRecBind</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867220"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867219"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867218"><span class="hs-identifier hs-var">top_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867216"><span class="hs-identifier hs-var">binder</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867215"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867214"><span class="hs-identifier hs-var">body_usage</span></a></span><span>
</span><span id="line-781"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalBind"><span class="hs-identifier hs-var">occAnalBind</span></a></span><span> </span><span id="local-6989586621680867212"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867212"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867211"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867211"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680867210"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867210"><span class="hs-identifier hs-var">top_env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680867208"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867208"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867207"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867207"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span>
</span><span id="line-782"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; [(CoreBndr, CoreExpr)]
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRecBind"><span class="hs-identifier hs-var">occAnalRecBind</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867212"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867211"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867210"><span class="hs-identifier hs-var">top_env</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867208"><span class="hs-identifier hs-var">pairs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867207"><span class="hs-identifier hs-var">body_usage</span></a></span><span>
</span><span id="line-783"></span><span>
</span><span id="line-784"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-785"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalNonRecBind"><span class="hs-identifier hs-type">occAnalNonRecBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-type">ImpRuleEdges</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-786"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span id="occAnalNonRecBind"><span class="annot"><span class="annottext">occAnalNonRecBind :: OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; CoreBndr
-&gt; CoreExpr
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalNonRecBind"><span class="hs-identifier hs-var hs-var">occAnalNonRecBind</span></a></span></span><span> </span><span id="local-6989586621680867205"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867205"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867204"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867204"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680867203"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867203"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span></span><span> </span><span id="local-6989586621680867202"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680867201"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867201"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span id="local-6989586621680867200"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867200"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span>
</span><span id="line-788"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span>      </span><span class="hs-comment">-- A type let; we don't gather usage info</span><span>
</span><span id="line-789"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867200"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867201"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-790"></span><span>
</span><span id="line-791"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#usedIn"><span class="hs-operator hs-var">`usedIn`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867200"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- It's not mentioned</span><span>
</span><span id="line-792"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867200"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-793"></span><span>
</span><span id="line-794"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                   </span><span class="hs-comment">-- It's mentioned in the body</span><span>
</span><span id="line-795"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867197"><span class="hs-identifier hs-var">body_usage'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867195"><span class="hs-identifier hs-var">rhs_usage4</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867194"><span class="hs-identifier hs-var">final_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867193"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-796"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-797"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867197"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867197"><span class="hs-identifier hs-var">body_usage'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867192"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867192"><span class="hs-identifier hs-var">tagged_bndr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagNonRecBinder"><span class="hs-identifier hs-var">tagNonRecBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867204"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867200"><span class="hs-identifier hs-var">body_usage</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-798"></span><span>    </span><span id="local-6989586621680867190"><span class="annot"><span class="annottext">occ :: OccInfo
</span><a href="#local-6989586621680867190"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867192"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span>
</span><span id="line-799"></span><span>
</span><span id="line-800"></span><span>    </span><span class="hs-comment">-- Get the join info from the *new* decision</span><span>
</span><span id="line-801"></span><span>    </span><span class="hs-comment">-- See Note [Join points and unfoldings/rules]</span><span>
</span><span id="line-802"></span><span>    </span><span id="local-6989586621680867188"><span class="annot"><span class="annottext">mb_join_arity :: Maybe JoinArity
</span><a href="#local-6989586621680867188"><span class="hs-identifier hs-var hs-var">mb_join_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#willBeJoinId_maybe"><span class="hs-identifier hs-var">willBeJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867192"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span>
</span><span id="line-803"></span><span>    </span><span id="local-6989586621680867186"><span class="annot"><span class="annottext">is_join_point :: Bool
</span><a href="#local-6989586621680867186"><span class="hs-identifier hs-var hs-var">is_join_point</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680867188"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span>
</span><span id="line-804"></span><span>
</span><span id="line-805"></span><span>    </span><span id="local-6989586621680867194"><span class="annot"><span class="annottext">final_bndr :: CoreBndr
</span><a href="#local-6989586621680867194"><span class="hs-identifier hs-var hs-var">final_bndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867192"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680867184"><span class="hs-identifier hs-var">unf'</span></a></span><span>
</span><span id="line-806"></span><span>                             </span><span class="annot"><span class="annottext">CoreBndr -&gt; RuleInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdSpecialisation"><span class="hs-operator hs-var">`setIdSpecialisation`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; RuleInfo
</span><a href="GHC.Core.FVs.html#mkRuleInfo"><span class="hs-identifier hs-var">mkRuleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680867181"><span class="hs-identifier hs-var">rules'</span></a></span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span>    </span><span id="local-6989586621680867180"><span class="annot"><span class="annottext">env1 :: OccEnv
</span><a href="#local-6989586621680867180"><span class="hs-identifier hs-var hs-var">env1</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867186"><span class="hs-identifier hs-var">is_join_point</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867205"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="hs-comment">-- See Note [Join point RHSs]</span><span>
</span><span id="line-809"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867179"><span class="hs-identifier hs-var">certainly_inline</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867205"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="hs-comment">-- See Note [Cascading inlines]</span><span>
</span><span id="line-810"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#rhsCtxt"><span class="hs-identifier hs-var">rhsCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867205"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-811"></span><span>
</span><span id="line-812"></span><span>    </span><span class="hs-comment">-- See Note [Sources of one-shot information]</span><span>
</span><span id="line-813"></span><span>    </span><span id="local-6989586621680867177"><span class="annot"><span class="annottext">rhs_env :: OccEnv
</span><a href="#local-6989586621680867177"><span class="hs-identifier hs-var hs-var">rhs_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867180"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Demand -&gt; OneShots
</span><a href="GHC.Types.Demand.html#argOneShots"><span class="hs-identifier hs-var">argOneShots</span></a></span><span> </span><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680867175"><span class="hs-identifier hs-var">dmd</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-814"></span><span>
</span><span id="line-815"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867174"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867174"><span class="hs-identifier hs-var">rhs_usage1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867193"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867193"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Maybe JoinArity -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRhs"><span class="hs-identifier hs-var">occAnalRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867177"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680867188"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867201"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-816"></span><span>
</span><span id="line-817"></span><span>    </span><span class="hs-comment">-- Unfoldings</span><span>
</span><span id="line-818"></span><span>    </span><span class="hs-comment">-- See Note [Unfoldings and join points]</span><span>
</span><span id="line-819"></span><span>    </span><span id="local-6989586621680867172"><span class="annot"><span class="annottext">unf :: Unfolding
</span><a href="#local-6989586621680867172"><span class="hs-identifier hs-var hs-var">unf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-820"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867170"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867170"><span class="hs-identifier hs-var">unf_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867184"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680867184"><span class="hs-identifier hs-var">unf'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Maybe JoinArity -&gt; Unfolding -&gt; (UsageDetails, Unfolding)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalUnfolding"><span class="hs-identifier hs-var">occAnalUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867177"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680867188"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680867172"><span class="hs-identifier hs-var">unf</span></a></span><span>
</span><span id="line-821"></span><span>    </span><span id="local-6989586621680867168"><span class="annot"><span class="annottext">rhs_usage2 :: UsageDetails
</span><a href="#local-6989586621680867168"><span class="hs-identifier hs-var hs-var">rhs_usage2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867174"><span class="hs-identifier hs-var">rhs_usage1</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867170"><span class="hs-identifier hs-var">unf_usage</span></a></span><span>
</span><span id="line-822"></span><span>
</span><span id="line-823"></span><span>    </span><span class="hs-comment">-- Rules</span><span>
</span><span id="line-824"></span><span>    </span><span class="hs-comment">-- See Note [Rules are extra RHSs] and Note [Rule dependency info]</span><span>
</span><span id="line-825"></span><span>    </span><span id="local-6989586621680867167"><span class="annot"><span class="annottext">rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680867167"><span class="hs-identifier hs-var hs-var">rules_w_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; Maybe JoinArity
-&gt; CoreBndr
-&gt; [(CoreRule, UsageDetails, UsageDetails)]
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRules"><span class="hs-identifier hs-var">occAnalRules</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867177"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680867188"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-826"></span><span>    </span><span id="local-6989586621680867165"><span class="annot"><span class="annottext">rule_uds :: [UsageDetails]
</span><a href="#local-6989586621680867165"><span class="hs-identifier hs-var hs-var">rule_uds</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreRule, UsageDetails, UsageDetails) -&gt; UsageDetails)
-&gt; [(CoreRule, UsageDetails, UsageDetails)] -&gt; [UsageDetails]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867164"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867164"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867163"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867163"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867164"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867163"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680867167"><span class="hs-identifier hs-var">rules_w_uds</span></a></span><span>
</span><span id="line-827"></span><span>    </span><span id="local-6989586621680867181"><span class="annot"><span class="annottext">rules' :: [CoreRule]
</span><a href="#local-6989586621680867181"><span class="hs-identifier hs-var hs-var">rules'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreRule, UsageDetails, UsageDetails) -&gt; CoreRule)
-&gt; [(CoreRule, UsageDetails, UsageDetails)] -&gt; [CoreRule]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreRule, UsageDetails, UsageDetails) -&gt; CoreRule
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680867167"><span class="hs-identifier hs-var">rules_w_uds</span></a></span><span>
</span><span id="line-828"></span><span>    </span><span id="local-6989586621680867160"><span class="annot"><span class="annottext">rhs_usage3 :: UsageDetails
</span><a href="#local-6989586621680867160"><span class="hs-identifier hs-var hs-var">rhs_usage3</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [UsageDetails] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-var">andUDs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867168"><span class="hs-identifier hs-var">rhs_usage2</span></a></span><span> </span><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680867165"><span class="hs-identifier hs-var">rule_uds</span></a></span><span>
</span><span id="line-829"></span><span>    </span><span id="local-6989586621680867195"><span class="annot"><span class="annottext">rhs_usage4 :: UsageDetails
</span><a href="#local-6989586621680867195"><span class="hs-identifier hs-var hs-var">rhs_usage4</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; CoreBndr -&gt; Maybe VarSet
forall a. VarEnv a -&gt; CoreBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867203"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-830"></span><span>                   </span><span class="annot"><span class="annottext">Maybe VarSet
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867160"><span class="hs-identifier hs-var">rhs_usage3</span></a></span><span>
</span><span id="line-831"></span><span>                   </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680867158"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867158"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var">addManyOccs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867160"><span class="hs-identifier hs-var">rhs_usage3</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867158"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-832"></span><span>       </span><span class="hs-comment">-- See Note [Preventing loops due to imported functions rules]</span><span>
</span><span id="line-833"></span><span>
</span><span id="line-834"></span><span>    </span><span id="local-6989586621680867179"><span class="annot"><span class="annottext">certainly_inline :: Bool
</span><a href="#local-6989586621680867179"><span class="hs-identifier hs-var hs-var">certainly_inline</span></a></span></span><span> </span><span class="hs-comment">-- See Note [Cascading inlines]</span><span>
</span><span id="line-835"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680867190"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-836"></span><span>          </span><span class="annot"><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: OccInfo -&gt; InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InsideLam
</span><a href="GHC.Types.Basic.html#NotInsideLam"><span class="hs-identifier hs-var">NotInsideLam</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_n_br :: OccInfo -&gt; JoinArity
</span><a href="GHC.Types.Basic.html#occ_n_br"><span class="hs-identifier hs-var">occ_n_br</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-837"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867151"><span class="hs-identifier hs-var">active</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867149"><span class="hs-identifier hs-var">not_stable</span></a></span><span>
</span><span id="line-838"></span><span>          </span><span class="annot"><span class="annottext">OccInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-839"></span><span>
</span><span id="line-840"></span><span>    </span><span id="local-6989586621680867175"><span class="annot"><span class="annottext">dmd :: Demand
</span><a href="#local-6989586621680867175"><span class="hs-identifier hs-var hs-var">dmd</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Demand
</span><a href="GHC.Types.Id.html#idDemandInfo"><span class="hs-identifier hs-var">idDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-841"></span><span>    </span><span id="local-6989586621680867151"><span class="annot"><span class="annottext">active :: Bool
</span><a href="#local-6989586621680867151"><span class="hs-identifier hs-var hs-var">active</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAlwaysActive"><span class="hs-identifier hs-var">isAlwaysActive</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-842"></span><span>    </span><span id="local-6989586621680867149"><span class="annot"><span class="annottext">not_stable :: Bool
</span><a href="#local-6989586621680867149"><span class="hs-identifier hs-var hs-var">not_stable</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#isStableUnfolding"><span class="hs-identifier hs-var">isStableUnfolding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867202"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-843"></span><span>
</span><span id="line-844"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-845"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalRecBind"><span class="hs-identifier hs-type">occAnalRecBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-type">ImpRuleEdges</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-846"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-847"></span><span id="occAnalRecBind"><span class="annot"><span class="annottext">occAnalRecBind :: OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; [(CoreBndr, CoreExpr)]
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRecBind"><span class="hs-identifier hs-var hs-var">occAnalRecBind</span></a></span></span><span> </span><span id="local-6989586621680867144"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867144"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867143"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867143"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680867142"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867142"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span></span><span> </span><span id="local-6989586621680867141"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867141"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span id="local-6989586621680867140"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867140"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span>
</span><span id="line-848"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SCC Details
 -&gt; (UsageDetails, CoreProgram) -&gt; (UsageDetails, CoreProgram))
-&gt; (UsageDetails, CoreProgram)
-&gt; [SCC Details]
-&gt; (UsageDetails, CoreProgram)
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; SCC Details
-&gt; (UsageDetails, CoreProgram)
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRec"><span class="hs-identifier hs-var">occAnalRec</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867138"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867143"><span class="hs-identifier hs-var">lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867140"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[SCC Details]
</span><a href="#local-6989586621680867137"><span class="hs-identifier hs-var">sccs</span></a></span><span>
</span><span id="line-849"></span><span>        </span><span class="hs-comment">-- For a recursive group, we</span><span>
</span><span id="line-850"></span><span>        </span><span class="hs-comment">--      * occ-analyse all the RHSs</span><span>
</span><span id="line-851"></span><span>        </span><span class="hs-comment">--      * compute strongly-connected components</span><span>
</span><span id="line-852"></span><span>        </span><span class="hs-comment">--      * feed those components to occAnalRec</span><span>
</span><span id="line-853"></span><span>        </span><span class="hs-comment">-- See Note [Recursive bindings: the grand plan]</span><span>
</span><span id="line-854"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-855"></span><span>    </span><span class="annot"><a href="#local-6989586621680867137"><span class="hs-identifier hs-type">sccs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../containers/src/Data.Graph.html#SCC"><span class="hs-identifier hs-type">SCC</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-856"></span><span>    </span><span id="local-6989586621680867137"><span class="annot"><span class="annottext">sccs :: [SCC Details]
</span><a href="#local-6989586621680867137"><span class="hs-identifier hs-var hs-var">sccs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;occAnalBind.scc&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-857"></span><span>           </span><span class="annot"><span class="annottext">[Node Unique Details] -&gt; [SCC Details]
forall key payload.
Uniquable key =&gt;
[Node key payload] -&gt; [SCC payload]
</span><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesUniq"><span class="hs-identifier hs-var">stronglyConnCompFromEdgedVerticesUniq</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867136"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span>    </span><span class="annot"><a href="#local-6989586621680867136"><span class="hs-identifier hs-type">nodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-860"></span><span>    </span><span id="local-6989586621680867136"><span class="annot"><span class="annottext">nodes :: [Node Unique Details]
</span><a href="#local-6989586621680867136"><span class="hs-identifier hs-var hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;occAnalBind.assoc&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-861"></span><span>            </span><span class="annot"><span class="annottext">((CoreBndr, CoreExpr) -&gt; Node Unique Details)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [Node Unique Details]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
-&gt; ImpRuleEdges
-&gt; VarSet
-&gt; (CoreBndr, CoreExpr)
-&gt; Node Unique Details
</span><a href="GHC.Core.Opt.OccurAnal.html#makeNode"><span class="hs-identifier hs-var">makeNode</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867138"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867142"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867133"><span class="hs-identifier hs-var">bndr_set</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867141"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-862"></span><span>
</span><span id="line-863"></span><span>    </span><span id="local-6989586621680867132"><span class="annot"><span class="annottext">bndrs :: [CoreBndr]
</span><a href="#local-6989586621680867132"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreBndr, CoreExpr) -&gt; CoreBndr)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [CoreBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, CoreExpr) -&gt; CoreBndr
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867141"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-864"></span><span>    </span><span id="local-6989586621680867133"><span class="annot"><span class="annottext">bndr_set :: VarSet
</span><a href="#local-6989586621680867133"><span class="hs-identifier hs-var hs-var">bndr_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867132"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-865"></span><span>    </span><span id="local-6989586621680867138"><span class="annot"><span class="annottext">rhs_env :: OccEnv
</span><a href="#local-6989586621680867138"><span class="hs-identifier hs-var hs-var">rhs_env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867144"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867132"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-866"></span><span>
</span><span id="line-867"></span><span class="hs-comment">{-
Note [Unfoldings and join points]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We assume that anything in an unfolding occurs multiple times, since unfoldings
are often copied (that's the whole point!). But we still need to track tail
calls for the purpose of finding join points.
-}</span><span>
</span><span id="line-875"></span><span>
</span><span id="line-876"></span><span class="hs-comment">-----------------------------</span><span>
</span><span id="line-877"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalRec"><span class="hs-identifier hs-type">occAnalRec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>
</span><span id="line-878"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#SCC"><span class="hs-identifier hs-type">SCC</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span><span>
</span><span id="line-879"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-880"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-881"></span><span>
</span><span id="line-882"></span><span>        </span><span class="hs-comment">-- The NonRec case is just like a Let (NonRec ...) above</span><span>
</span><span id="line-883"></span><span id="occAnalRec"><span class="annot"><span class="annottext">occAnalRec :: OccEnv
-&gt; TopLevelFlag
-&gt; SCC Details
-&gt; (UsageDetails, CoreProgram)
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRec"><span class="hs-identifier hs-var hs-var">occAnalRec</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680867129"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867129"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#AcyclicSCC"><span class="hs-identifier hs-type">AcyclicSCC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867125"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867125"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs :: Details -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var">nd_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867123"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867123"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-884"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_uds :: Details -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_uds"><span class="hs-identifier hs-var">nd_uds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867121"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867121"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs_bndrs :: Details -&gt; [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs_bndrs"><span class="hs-identifier hs-var">nd_rhs_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867119"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867119"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-885"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621680867118"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867118"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867117"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867117"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-886"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867125"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#usedIn"><span class="hs-operator hs-var">`usedIn`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867118"><span class="hs-identifier hs-var">body_uds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-887"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867118"><span class="hs-identifier hs-var">body_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867117"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>           </span><span class="hs-comment">-- See Note [Dead code]</span><span>
</span><span id="line-888"></span><span>
</span><span id="line-889"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                   </span><span class="hs-comment">-- It's mentioned in the body</span><span>
</span><span id="line-890"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867116"><span class="hs-identifier hs-var">body_uds'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867115"><span class="hs-identifier hs-var">rhs_uds'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-891"></span><span>     </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867114"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867123"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreProgram -&gt; CoreProgram
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867117"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-892"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-893"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867116"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867116"><span class="hs-identifier hs-var">body_uds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867114"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867114"><span class="hs-identifier hs-var">tagged_bndr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagNonRecBinder"><span class="hs-identifier hs-var">tagNonRecBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867129"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867118"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867125"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-894"></span><span>    </span><span id="local-6989586621680867115"><span class="annot"><span class="annottext">rhs_uds' :: UsageDetails
</span><a href="#local-6989586621680867115"><span class="hs-identifier hs-var hs-var">rhs_uds'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
-&gt; RecFlag -&gt; [CoreBndr] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#adjustRhsUsage"><span class="hs-identifier hs-var">adjustRhsUsage</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#willBeJoinId_maybe"><span class="hs-identifier hs-var">willBeJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867114"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span>
</span><span id="line-895"></span><span>                              </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867119"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867121"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span>
</span><span id="line-896"></span><span>
</span><span id="line-897"></span><span>        </span><span class="hs-comment">-- The Rec case is the interesting one</span><span>
</span><span id="line-898"></span><span>        </span><span class="hs-comment">-- See Note [Recursive bindings: the grand plan]</span><span>
</span><span id="line-899"></span><span>        </span><span class="hs-comment">-- See Note [Loop breaking]</span><span>
</span><span id="line-900"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalRec"><span class="hs-identifier hs-var">occAnalRec</span></a></span><span> </span><span id="local-6989586621680867111"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867111"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867110"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867110"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#CyclicSCC"><span class="hs-identifier hs-type">CyclicSCC</span></a></span><span> </span><span id="local-6989586621680867108"><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680867108"><span class="hs-identifier hs-var">details_s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867107"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867107"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867106"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867106"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-901"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#usedIn"><span class="hs-operator hs-var">`usedIn`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867107"><span class="hs-identifier hs-var">body_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867104"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- NB: look at body_uds, not total_uds</span><span>
</span><span id="line-902"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867107"><span class="hs-identifier hs-var">body_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867106"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>                   </span><span class="hs-comment">-- See Note [Dead code]</span><span>
</span><span id="line-903"></span><span>
</span><span id="line-904"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- At this point we always build a single Rec</span><span>
</span><span id="line-905"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;occAnalRec&quot; (vcat</span><span>
</span><span id="line-906"></span><span>    </span><span class="hs-comment">--   [ text &quot;weak_fvs&quot; &lt;+&gt; ppr weak_fvs</span><span>
</span><span id="line-907"></span><span>    </span><span class="hs-comment">--   , text &quot;lb nodes&quot; &lt;+&gt; ppr loop_breaker_nodes])</span><span>
</span><span id="line-908"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867103"><span class="hs-identifier hs-var">final_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867102"><span class="hs-identifier hs-var">pairs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreProgram -&gt; CoreProgram
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680867106"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-909"></span><span>
</span><span id="line-910"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-911"></span><span>    </span><span id="local-6989586621680867104"><span class="annot"><span class="annottext">bndrs :: [CoreBndr]
</span><a href="#local-6989586621680867104"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Details -&gt; CoreBndr) -&gt; [Details] -&gt; [CoreBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var hs-var">nd_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680867108"><span class="hs-identifier hs-var">details_s</span></a></span><span>
</span><span id="line-912"></span><span>    </span><span id="local-6989586621680867101"><span class="annot"><span class="annottext">bndr_set :: VarSet
</span><a href="#local-6989586621680867101"><span class="hs-identifier hs-var hs-var">bndr_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680867104"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-913"></span><span>
</span><span id="line-914"></span><span>    </span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-915"></span><span>        </span><span class="hs-comment">-- See Note [Choosing loop breakers] for loop_breaker_nodes</span><span>
</span><span id="line-916"></span><span>    </span><span class="annot"><a href="#local-6989586621680867103"><span class="hs-identifier hs-type">final_uds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-917"></span><span>    </span><span class="annot"><a href="#local-6989586621680867100"><span class="hs-identifier hs-type">loop_breaker_nodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-918"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867103"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867103"><span class="hs-identifier hs-var">final_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867100"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867100"><span class="hs-identifier hs-var">loop_breaker_nodes</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-919"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; VarSet
-&gt; UsageDetails
-&gt; [Details]
-&gt; (UsageDetails, [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#mkLoopBreakerNodes"><span class="hs-identifier hs-var">mkLoopBreakerNodes</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867111"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680867110"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867101"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680867107"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680867108"><span class="hs-identifier hs-var">details_s</span></a></span><span>
</span><span id="line-920"></span><span>
</span><span id="line-921"></span><span>    </span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-922"></span><span>    </span><span class="annot"><a href="#local-6989586621680867098"><span class="hs-identifier hs-type">weak_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-923"></span><span>    </span><span id="local-6989586621680867098"><span class="annot"><span class="annottext">weak_fvs :: VarSet
</span><a href="#local-6989586621680867098"><span class="hs-identifier hs-var hs-var">weak_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Details -&gt; VarSet) -&gt; [Details] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_weak"><span class="hs-identifier hs-var hs-var">nd_weak</span></a></span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680867108"><span class="hs-identifier hs-var">details_s</span></a></span><span>
</span><span id="line-924"></span><span>
</span><span id="line-925"></span><span>    </span><span class="hs-comment">---------------------------</span><span>
</span><span id="line-926"></span><span>    </span><span class="hs-comment">-- Now reconstruct the cycle</span><span>
</span><span id="line-927"></span><span>    </span><span class="annot"><a href="#local-6989586621680867102"><span class="hs-identifier hs-type">pairs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-928"></span><span>    </span><span id="local-6989586621680867102"><span class="annot"><span class="annottext">pairs :: [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867102"><span class="hs-identifier hs-var hs-var">pairs</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867098"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-var">reOrderNodes</span></a></span><span>   </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867101"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867098"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867100"><span class="hs-identifier hs-var">loop_breaker_nodes</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-929"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#loopBreakNodes"><span class="hs-identifier hs-var">loopBreakNodes</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867101"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867098"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867100"><span class="hs-identifier hs-var">loop_breaker_nodes</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-930"></span><span>          </span><span class="hs-comment">-- If weak_fvs is empty, the loop_breaker_nodes will include</span><span>
</span><span id="line-931"></span><span>          </span><span class="hs-comment">-- all the edges in the original scope edges [remember,</span><span>
</span><span id="line-932"></span><span>          </span><span class="hs-comment">-- weak_fvs is the difference between scope edges and</span><span>
</span><span id="line-933"></span><span>          </span><span class="hs-comment">-- lb-edges], so a fresh SCC computation would yield a</span><span>
</span><span id="line-934"></span><span>          </span><span class="hs-comment">-- single CyclicSCC result; and reOrderNodes deals with</span><span>
</span><span id="line-935"></span><span>          </span><span class="hs-comment">-- exactly that case</span><span>
</span><span id="line-936"></span><span>
</span><span id="line-937"></span><span>
</span><span id="line-938"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-939"></span><span class="hs-comment">--                 Loop breaking</span><span>
</span><span id="line-940"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-941"></span><span>
</span><span id="line-942"></span><span class="hs-keyword">type</span><span> </span><span id="Binding"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-var">Binding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-943"></span><span>
</span><span id="line-944"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#loopBreakNodes"><span class="hs-identifier hs-type">loopBreakNodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-945"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>        </span><span class="hs-comment">-- All binders</span><span>
</span><span id="line-946"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>        </span><span class="hs-comment">-- Binders whose dependencies may be &quot;missing&quot;</span><span>
</span><span id="line-947"></span><span>                                </span><span class="hs-comment">-- See Note [Weak loop breakers]</span><span>
</span><span id="line-948"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-949"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span>             </span><span class="hs-comment">-- Append these to the end</span><span>
</span><span id="line-950"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-951"></span><span class="hs-comment">{-
loopBreakNodes is applied to the list of nodes for a cyclic strongly
connected component (there's guaranteed to be a cycle).  It returns
the same nodes, but
        a) in a better order,
        b) with some of the Ids having a IAmALoopBreaker pragma

The &quot;loop-breaker&quot; Ids are sufficient to break all cycles in the SCC.  This means
that the simplifier can guarantee not to loop provided it never records an inlining
for these no-inline guys.

Furthermore, the order of the binds is such that if we neglect dependencies
on the no-inline Ids then the binds are topologically sorted.  This means
that the simplifier will generally do a good job if it works from top bottom,
recording inlinings for any Ids which aren't marked as &quot;no-inline&quot; as it goes.
-}</span><span>
</span><span id="line-967"></span><span>
</span><span id="line-968"></span><span class="hs-comment">-- Return the bindings sorted into a plausible order, and marked with loop breakers.</span><span>
</span><span id="line-969"></span><span id="loopBreakNodes"><span class="annot"><span class="annottext">loopBreakNodes :: JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#loopBreakNodes"><span class="hs-identifier hs-var hs-var">loopBreakNodes</span></a></span></span><span> </span><span id="local-6989586621680867091"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867091"><span class="hs-identifier hs-var">depth</span></a></span></span><span> </span><span id="local-6989586621680867090"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867090"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span> </span><span id="local-6989586621680867089"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867089"><span class="hs-identifier hs-var">weak_fvs</span></a></span></span><span> </span><span id="local-6989586621680867088"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867088"><span class="hs-identifier hs-var">nodes</span></a></span></span><span> </span><span id="local-6989586621680867087"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867087"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-970"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;loopBreakNodes&quot; (ppr nodes) $</span><span>
</span><span id="line-971"></span><span>    </span><span class="annot"><span class="annottext">[SCC (Node Unique Details)] -&gt; [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867086"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Node Unique Details] -&gt; [SCC (Node Unique Details)]
forall key payload.
Uniquable key =&gt;
[Node key payload] -&gt; [SCC (Node key payload)]
</span><a href="GHC.Data.Graph.Directed.html#stronglyConnCompFromEdgedVerticesUniqR"><span class="hs-identifier hs-var">stronglyConnCompFromEdgedVerticesUniqR</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867088"><span class="hs-identifier hs-var">nodes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-972"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-973"></span><span>    </span><span id="local-6989586621680867086"><span class="annot"><span class="annottext">go :: [SCC (Node Unique Details)] -&gt; [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867086"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867087"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-974"></span><span>    </span><span class="annot"><a href="#local-6989586621680867086"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867085"><span class="annot"><span class="annottext">SCC (Node Unique Details)
</span><a href="#local-6989586621680867085"><span class="hs-identifier hs-var">scc</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867084"><span class="annot"><span class="annottext">[SCC (Node Unique Details)]
</span><a href="#local-6989586621680867084"><span class="hs-identifier hs-var">sccs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SCC (Node Unique Details)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867083"><span class="hs-identifier hs-var">loop_break_scc</span></a></span><span> </span><span class="annot"><span class="annottext">SCC (Node Unique Details)
</span><a href="#local-6989586621680867085"><span class="hs-identifier hs-var">scc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SCC (Node Unique Details)] -&gt; [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867086"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[SCC (Node Unique Details)]
</span><a href="#local-6989586621680867084"><span class="hs-identifier hs-var">sccs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-975"></span><span>
</span><span id="line-976"></span><span>    </span><span id="local-6989586621680867083"><span class="annot"><span class="annottext">loop_break_scc :: SCC (Node Unique Details)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867083"><span class="hs-identifier hs-var hs-var">loop_break_scc</span></a></span></span><span> </span><span id="local-6989586621680867082"><span class="annot"><span class="annottext">SCC (Node Unique Details)
</span><a href="#local-6989586621680867082"><span class="hs-identifier hs-var">scc</span></a></span></span><span> </span><span id="local-6989586621680867081"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867081"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-977"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SCC (Node Unique Details)
</span><a href="#local-6989586621680867082"><span class="hs-identifier hs-var">scc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-978"></span><span>          </span><span class="annot"><a href="../../containers/src/Data.Graph.html#AcyclicSCC"><span class="hs-identifier hs-type">AcyclicSCC</span></a></span><span> </span><span id="local-6989586621680867080"><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867080"><span class="hs-identifier hs-var">node</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Node Unique Details -&gt; (CoreBndr, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#mk_non_loop_breaker"><span class="hs-identifier hs-var">mk_non_loop_breaker</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867089"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867080"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, CoreExpr)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867081"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-979"></span><span>          </span><span class="annot"><a href="../../containers/src/Data.Graph.html#CyclicSCC"><span class="hs-identifier hs-type">CyclicSCC</span></a></span><span> </span><span id="local-6989586621680867078"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867078"><span class="hs-identifier hs-var">nodes</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-var">reOrderNodes</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867091"><span class="hs-identifier hs-var">depth</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867090"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867089"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867078"><span class="hs-identifier hs-var">nodes</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867081"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-980"></span><span>
</span><span id="line-981"></span><span class="hs-comment">----------------------------------</span><span>
</span><span id="line-982"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-type">reOrderNodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-983"></span><span>    </span><span class="hs-comment">-- Choose a loop breaker, mark it no-inline,</span><span>
</span><span id="line-984"></span><span>    </span><span class="hs-comment">-- and call loopBreakNodes on the rest</span><span>
</span><span id="line-985"></span><span id="reOrderNodes"><span class="annot"><span class="annottext">reOrderNodes :: JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-var hs-var">reOrderNodes</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [(CoreBndr, CoreExpr)]
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reOrderNodes&quot;</span></span><span>
</span><span id="line-986"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-var">reOrderNodes</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621680867076"><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867076"><span class="hs-identifier hs-var">node</span></a></span></span><span class="hs-special">]</span><span> </span><span id="local-6989586621680867075"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867075"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Node Unique Details -&gt; (CoreBndr, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#mk_loop_breaker"><span class="hs-identifier hs-var">mk_loop_breaker</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867076"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, CoreExpr)
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867075"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-987"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#reOrderNodes"><span class="hs-identifier hs-var">reOrderNodes</span></a></span><span> </span><span id="local-6989586621680867073"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867073"><span class="hs-identifier hs-var">depth</span></a></span></span><span> </span><span id="local-6989586621680867072"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867072"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span> </span><span id="local-6989586621680867071"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867071"><span class="hs-identifier hs-var">weak_fvs</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867070"><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867070"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867069"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867069"><span class="hs-identifier hs-var">nodes</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867068"><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867068"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-988"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;reOrderNodes&quot; (vcat [ text &quot;unchosen&quot; &lt;+&gt; ppr unchosen</span><span>
</span><span id="line-989"></span><span>    </span><span class="hs-comment">--                               , text &quot;chosen&quot; &lt;+&gt; ppr chosen_nodes ]) $</span><span>
</span><span id="line-990"></span><span>    </span><span class="annot"><span class="annottext">JoinArity
-&gt; VarSet
-&gt; VarSet
-&gt; [Node Unique Details]
-&gt; [(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)]
</span><a href="GHC.Core.Opt.OccurAnal.html#loopBreakNodes"><span class="hs-identifier hs-var">loopBreakNodes</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867067"><span class="hs-identifier hs-var">new_depth</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867072"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867071"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867066"><span class="hs-identifier hs-var">unchosen</span></a></span><span> </span><span class="annot"><span class="annottext">([(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)])
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-991"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Node Unique Details -&gt; (CoreBndr, CoreExpr))
-&gt; [Node Unique Details] -&gt; [(CoreBndr, CoreExpr)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details -&gt; (CoreBndr, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#mk_loop_breaker"><span class="hs-identifier hs-var">mk_loop_breaker</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867065"><span class="hs-identifier hs-var">chosen_nodes</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
-&gt; [(CoreBndr, CoreExpr)] -&gt; [(CoreBndr, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, CoreExpr)]
</span><a href="#local-6989586621680867068"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-992"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-993"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867065"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867065"><span class="hs-identifier hs-var">chosen_nodes</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867066"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867066"><span class="hs-identifier hs-var">unchosen</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; NodeScore
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; ([Node Unique Details], [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var">chooseLoopBreaker</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867063"><span class="hs-identifier hs-var">approximate_lb</span></a></span><span>
</span><span id="line-994"></span><span>                                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var hs-var">nd_score</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details -&gt; Details
forall key payload. Node key payload -&gt; payload
</span><a href="GHC.Data.Graph.Directed.html#node_payload"><span class="hs-identifier hs-var hs-var">node_payload</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867070"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-995"></span><span>                                                 </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867070"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867069"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-996"></span><span>
</span><span id="line-997"></span><span>    </span><span id="local-6989586621680867063"><span class="annot"><span class="annottext">approximate_lb :: Bool
</span><a href="#local-6989586621680867063"><span class="hs-identifier hs-var hs-var">approximate_lb</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867073"><span class="hs-identifier hs-var">depth</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">2</span></span><span>
</span><span id="line-998"></span><span>    </span><span id="local-6989586621680867067"><span class="annot"><span class="annottext">new_depth :: JoinArity
</span><a href="#local-6989586621680867067"><span class="hs-identifier hs-var hs-var">new_depth</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867063"><span class="hs-identifier hs-var">approximate_lb</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-999"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867073"><span class="hs-identifier hs-var">depth</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1000"></span><span>        </span><span class="hs-comment">-- After two iterations (d=0, d=1) give up</span><span>
</span><span id="line-1001"></span><span>        </span><span class="hs-comment">-- and approximate, returning to d=0</span><span>
</span><span id="line-1002"></span><span>
</span><span id="line-1003"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#mk_loop_breaker"><span class="hs-identifier hs-type">mk_loop_breaker</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span>
</span><span id="line-1004"></span><span id="mk_loop_breaker"><span class="annot"><span class="annottext">mk_loop_breaker :: Node Unique Details -&gt; (CoreBndr, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#mk_loop_breaker"><span class="hs-identifier hs-var hs-var">mk_loop_breaker</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details -&gt; Details
forall key payload. Node key payload -&gt; payload
</span><a href="GHC.Data.Graph.Directed.html#node_payload"><span class="hs-identifier hs-var hs-var">node_payload</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867054"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867054"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs :: Details -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var">nd_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867053"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867053"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1005"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867054"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdOccInfo"><span class="hs-operator hs-var">`setIdOccInfo`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#strongLoopBreaker"><span class="hs-identifier hs-var">strongLoopBreaker</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680867049"><span class="hs-identifier hs-var">tail_info</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867053"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1006"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1007"></span><span>    </span><span id="local-6989586621680867049"><span class="annot"><span class="annottext">tail_info :: TailCallInfo
</span><a href="#local-6989586621680867049"><span class="hs-identifier hs-var hs-var">tail_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867054"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1008"></span><span>
</span><span id="line-1009"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#mk_non_loop_breaker"><span class="hs-identifier hs-type">mk_non_loop_breaker</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span>
</span><span id="line-1010"></span><span class="hs-comment">-- See Note [Weak loop breakers]</span><span>
</span><span id="line-1011"></span><span id="mk_non_loop_breaker"><span class="annot"><span class="annottext">mk_non_loop_breaker :: VarSet -&gt; Node Unique Details -&gt; (CoreBndr, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#mk_non_loop_breaker"><span class="hs-identifier hs-var hs-var">mk_non_loop_breaker</span></a></span></span><span> </span><span id="local-6989586621680867047"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867047"><span class="hs-identifier hs-var">weak_fvs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details -&gt; Details
forall key payload. Node key payload -&gt; payload
</span><a href="GHC.Data.Graph.Directed.html#node_payload"><span class="hs-identifier hs-var hs-var">node_payload</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867046"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867046"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-1012"></span><span>                                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs :: Details -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var">nd_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867045"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867045"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1013"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867046"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867047"><span class="hs-identifier hs-var">weak_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdOccInfo"><span class="hs-identifier hs-var">setIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867046"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680867043"><span class="hs-identifier hs-var">occ'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867045"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1014"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867046"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867045"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1015"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1016"></span><span>    </span><span id="local-6989586621680867043"><span class="annot"><span class="annottext">occ' :: OccInfo
</span><a href="#local-6989586621680867043"><span class="hs-identifier hs-var hs-var">occ'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#weakLoopBreaker"><span class="hs-identifier hs-var">weakLoopBreaker</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680867041"><span class="hs-identifier hs-var">tail_info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1017"></span><span>    </span><span id="local-6989586621680867041"><span class="annot"><span class="annottext">tail_info :: TailCallInfo
</span><a href="#local-6989586621680867041"><span class="hs-identifier hs-var hs-var">tail_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680867046"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1018"></span><span>
</span><span id="line-1019"></span><span class="hs-comment">----------------------------------</span><span>
</span><span id="line-1020"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-type">chooseLoopBreaker</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>             </span><span class="hs-comment">-- True &lt;=&gt; Too many iterations,</span><span>
</span><span id="line-1021"></span><span>                                      </span><span class="hs-comment">--          so approximate</span><span>
</span><span id="line-1022"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span>            </span><span class="hs-comment">-- Best score so far</span><span>
</span><span id="line-1023"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Nodes with this score</span><span>
</span><span id="line-1024"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Nodes with higher scores</span><span>
</span><span id="line-1025"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Unprocessed nodes</span><span>
</span><span id="line-1026"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1027"></span><span>    </span><span class="hs-comment">-- This loop looks for the bind with the lowest score</span><span>
</span><span id="line-1028"></span><span>    </span><span class="hs-comment">-- to pick as the loop  breaker.  The rest accumulate in</span><span>
</span><span id="line-1029"></span><span id="chooseLoopBreaker"><span class="annot"><span class="annottext">chooseLoopBreaker :: Bool
-&gt; NodeScore
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; ([Node Unique Details], [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var hs-var">chooseLoopBreaker</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680867040"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867040"><span class="hs-identifier hs-var">loop_nodes</span></a></span></span><span> </span><span id="local-6989586621680867039"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867039"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1030"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867040"><span class="hs-identifier hs-var">loop_nodes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867039"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>        </span><span class="hs-comment">-- Done</span><span>
</span><span id="line-1031"></span><span>
</span><span id="line-1032"></span><span>    </span><span class="hs-comment">-- If approximate_loop_breaker is True, we pick *all*</span><span>
</span><span id="line-1033"></span><span>    </span><span class="hs-comment">-- nodes with lowest score, else just one</span><span>
</span><span id="line-1034"></span><span>    </span><span class="hs-comment">-- See Note [Complexity of loop breaking]</span><span>
</span><span id="line-1035"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var">chooseLoopBreaker</span></a></span><span> </span><span id="local-6989586621680867038"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867038"><span class="hs-identifier hs-var">approx_lb</span></a></span></span><span> </span><span id="local-6989586621680867037"><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867037"><span class="hs-identifier hs-var">loop_sc</span></a></span></span><span> </span><span id="local-6989586621680867036"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867036"><span class="hs-identifier hs-var">loop_nodes</span></a></span></span><span> </span><span id="local-6989586621680867035"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867035"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867034"><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867034"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867033"><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867033"><span class="hs-identifier hs-var">nodes</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1036"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867038"><span class="hs-identifier hs-var">approx_lb</span></a></span><span>
</span><span id="line-1037"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NodeScore -&gt; JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#rank"><span class="hs-identifier hs-var">rank</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867031"><span class="hs-identifier hs-var">sc</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">NodeScore -&gt; JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#rank"><span class="hs-identifier hs-var">rank</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867037"><span class="hs-identifier hs-var">loop_sc</span></a></span><span>
</span><span id="line-1038"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; NodeScore
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; ([Node Unique Details], [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var">chooseLoopBreaker</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867038"><span class="hs-identifier hs-var">approx_lb</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867037"><span class="hs-identifier hs-var">loop_sc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867034"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
-&gt; [Node Unique Details] -&gt; [Node Unique Details]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867036"><span class="hs-identifier hs-var">loop_nodes</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867035"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867033"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-1039"></span><span>
</span><span id="line-1040"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867031"><span class="hs-identifier hs-var">sc</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore -&gt; NodeScore -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#betterLB"><span class="hs-operator hs-var">`betterLB`</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867037"><span class="hs-identifier hs-var">loop_sc</span></a></span><span>  </span><span class="hs-comment">-- Better score so pick this new one</span><span>
</span><span id="line-1041"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; NodeScore
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; ([Node Unique Details], [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var">chooseLoopBreaker</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867038"><span class="hs-identifier hs-var">approx_lb</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867031"><span class="hs-identifier hs-var">sc</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867034"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867036"><span class="hs-identifier hs-var">loop_nodes</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
-&gt; [Node Unique Details] -&gt; [Node Unique Details]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867035"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867033"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-1042"></span><span>
</span><span id="line-1043"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-comment">-- Worse score so don't pick it</span><span>
</span><span id="line-1044"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; NodeScore
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; [Node Unique Details]
-&gt; ([Node Unique Details], [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#chooseLoopBreaker"><span class="hs-identifier hs-var">chooseLoopBreaker</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867038"><span class="hs-identifier hs-var">approx_lb</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680867037"><span class="hs-identifier hs-var">loop_sc</span></a></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867036"><span class="hs-identifier hs-var">loop_nodes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867034"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
-&gt; [Node Unique Details] -&gt; [Node Unique Details]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867035"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Node Unique Details]
</span><a href="#local-6989586621680867033"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-1045"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1046"></span><span>    </span><span id="local-6989586621680867031"><span class="annot"><span class="annottext">sc :: NodeScore
</span><a href="#local-6989586621680867031"><span class="hs-identifier hs-var hs-var">sc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var hs-var">nd_score</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node Unique Details -&gt; Details
forall key payload. Node key payload -&gt; payload
</span><a href="GHC.Data.Graph.Directed.html#node_payload"><span class="hs-identifier hs-var hs-var">node_payload</span></a></span><span> </span><span class="annot"><span class="annottext">Node Unique Details
</span><a href="#local-6989586621680867034"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1047"></span><span>
</span><span id="line-1048"></span><span class="hs-comment">{-
Note [Complexity of loop breaking]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The loop-breaking algorithm knocks out one binder at a time, and
performs a new SCC analysis on the remaining binders.  That can
behave very badly in tightly-coupled groups of bindings; in the
worst case it can be (N**2)*log N, because it does a full SCC
on N, then N-1, then N-2 and so on.

To avoid this, we switch plans after 2 (or whatever) attempts:
  Plan A: pick one binder with the lowest score, make it
          a loop breaker, and try again
  Plan B: pick *all* binders with the lowest score, make them
          all loop breakers, and try again
Since there are only a small finite number of scores, this will
terminate in a constant number of iterations, rather than O(N)
iterations.

You might thing that it's very unlikely, but RULES make it much
more likely.  Here's a real example from #1969:
  Rec { $dm = \d.\x. op d
        {-# RULES forall d. $dm Int d  = $s$dm1
                  forall d. $dm Bool d = $s$dm2 #-}

        dInt = MkD .... opInt ...
        dInt = MkD .... opBool ...
        opInt  = $dm dInt
        opBool = $dm dBool

        $s$dm1 = \x. op dInt
        $s$dm2 = \x. op dBool }
The RULES stuff means that we can't choose $dm as a loop breaker
(Note [Choosing loop breakers]), so we must choose at least (say)
opInt *and* opBool, and so on.  The number of loop breakders is
linear in the number of instance declarations.

Note [Loop breakers and INLINE/INLINABLE pragmas]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Avoid choosing a function with an INLINE pramga as the loop breaker!
If such a function is mutually-recursive with a non-INLINE thing,
then the latter should be the loop-breaker.

It's vital to distinguish between INLINE and INLINABLE (the
Bool returned by hasStableCoreUnfolding_maybe).  If we start with
   Rec { {-# INLINABLE f #-}
         f x = ...f... }
and then worker/wrapper it through strictness analysis, we'll get
   Rec { {-# INLINABLE $wf #-}
         $wf p q = let x = (p,q) in ...f...

         {-# INLINE f #-}
         f x = case x of (p,q) -&gt; $wf p q }

Now it is vital that we choose $wf as the loop breaker, so we can
inline 'f' in '$wf'.

Note [DFuns should not be loop breakers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's particularly bad to make a DFun into a loop breaker.  See
Note [How instance declarations are translated] in GHC.Tc.TyCl.Instance

We give DFuns a higher score than ordinary CONLIKE things because
if there's a choice we want the DFun to be the non-loop breaker. Eg

rec { sc = /\ a \$dC. $fBWrap (T a) ($fCT @ a $dC)

      $fCT :: forall a_afE. (Roman.C a_afE) =&gt; Roman.C (Roman.T a_afE)
      {-# DFUN #-}
      $fCT = /\a \$dC. MkD (T a) ((sc @ a $dC) |&gt; blah) ($ctoF @ a $dC)
    }

Here 'sc' (the superclass) looks CONLIKE, but we'll never get to it
if we can't unravel the DFun first.

Note [Constructor applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's really really important to inline dictionaries.  Real
example (the Enum Ordering instance from GHC.Base):

     rec     f = \ x -&gt; case d of (p,q,r) -&gt; p x
             g = \ x -&gt; case d of (p,q,r) -&gt; q x
             d = (v, f, g)

Here, f and g occur just once; but we can't inline them into d.
On the other hand we *could* simplify those case expressions if
we didn't stupidly choose d as the loop breaker.
But we won't because constructor args are marked &quot;Many&quot;.
Inlining dictionaries is really essential to unravelling
the loops in static numeric dictionaries, see GHC.Float.

Note [Closure conversion]
~~~~~~~~~~~~~~~~~~~~~~~~~
We treat (\x. C p q) as a high-score candidate in the letrec scoring algorithm.
The immediate motivation came from the result of a closure-conversion transformation
which generated code like this:

    data Clo a b = forall c. Clo (c -&gt; a -&gt; b) c

    ($:) :: Clo a b -&gt; a -&gt; b
    Clo f env $: x = f env x

    rec { plus = Clo plus1 ()

        ; plus1 _ n = Clo plus2 n

        ; plus2 Zero     n = n
        ; plus2 (Succ m) n = Succ (plus $: m $: n) }

If we inline 'plus' and 'plus1', everything unravels nicely.  But if
we choose 'plus1' as the loop breaker (which is entirely possible
otherwise), the loop does not unravel nicely.


@occAnalUnfolding@ deals with the question of bindings where the Id is marked
by an INLINE pragma.  For these we record that anything which occurs
in its RHS occurs many times.  This pessimistically assumes that this
inlined binder also occurs many times in its scope, but if it doesn't
we'll catch it next time round.  At worst this costs an extra simplifier pass.
ToDo: try using the occurrence info for the inline'd binder.

[March 97] We do the same for atomic RHSs.  Reason: see notes with loopBreakSCC.
[June 98, SLPJ]  I've undone this change; I don't understand it.  See notes with loopBreakSCC.


************************************************************************
*                                                                      *
                   Making nodes
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1178"></span><span>
</span><span id="line-1179"></span><span class="hs-keyword">type</span><span> </span><span id="ImpRuleEdges"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-var">ImpRuleEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>     </span><span class="hs-comment">-- Mapping from FVs of imported RULE LHSs to RHS FVs</span><span>
</span><span id="line-1180"></span><span>
</span><span id="line-1181"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#noImpRuleEdges"><span class="hs-identifier hs-type">noImpRuleEdges</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-type">ImpRuleEdges</span></a></span><span>
</span><span id="line-1182"></span><span id="noImpRuleEdges"><span class="annot"><span class="annottext">noImpRuleEdges :: ImpRuleEdges
</span><a href="GHC.Core.Opt.OccurAnal.html#noImpRuleEdges"><span class="hs-identifier hs-var hs-var">noImpRuleEdges</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-1183"></span><span>
</span><span id="line-1184"></span><span class="hs-keyword">type</span><span> </span><span id="LetrecNode"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-var">LetrecNode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html#Node"><span class="hs-identifier hs-type">Node</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span><span>  </span><span class="hs-comment">-- Node comes from Digraph</span><span>
</span><span id="line-1185"></span><span>                                       </span><span class="hs-comment">-- The Unique key is gotten from the Id</span><span>
</span><span id="line-1186"></span><span class="hs-keyword">data</span><span> </span><span id="Details"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-var">Details</span></a></span></span><span>
</span><span id="line-1187"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="ND"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-var">ND</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="nd_bndr"><span class="annot"><span class="annottext">Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var hs-var">nd_bndr</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>          </span><span class="hs-comment">-- Binder</span><span>
</span><span id="line-1188"></span><span>
</span><span id="line-1189"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_rhs"><span class="annot"><span class="annottext">Details -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var hs-var">nd_rhs</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>    </span><span class="hs-comment">-- RHS, already occ-analysed</span><span>
</span><span id="line-1190"></span><span>
</span><span id="line-1191"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_rhs_bndrs"><span class="annot"><span class="annottext">Details -&gt; [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs_bndrs"><span class="hs-identifier hs-var hs-var">nd_rhs_bndrs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Outer lambdas of RHS</span><span>
</span><span id="line-1192"></span><span>                                    </span><span class="hs-comment">-- INVARIANT: (nd_rhs_bndrs nd, _) ==</span><span>
</span><span id="line-1193"></span><span>                                    </span><span class="hs-comment">--              collectBinders (nd_rhs nd)</span><span>
</span><span id="line-1194"></span><span>
</span><span id="line-1195"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_uds"><span class="annot"><span class="annottext">Details -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_uds"><span class="hs-identifier hs-var hs-var">nd_uds</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>  </span><span class="hs-comment">-- Usage from RHS, and RULES, and stable unfoldings</span><span>
</span><span id="line-1196"></span><span>                                  </span><span class="hs-comment">-- ignoring phase (ie assuming all are active)</span><span>
</span><span id="line-1197"></span><span>                                  </span><span class="hs-comment">-- See Note [Forming Rec groups]</span><span>
</span><span id="line-1198"></span><span>
</span><span id="line-1199"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_inl"><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_inl"><span class="hs-identifier hs-var hs-var">nd_inl</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>       </span><span class="hs-comment">-- Free variables of</span><span>
</span><span id="line-1200"></span><span>                                </span><span class="hs-comment">--   the stable unfolding (if present and active)</span><span>
</span><span id="line-1201"></span><span>                                </span><span class="hs-comment">--   or the RHS (if not)</span><span>
</span><span id="line-1202"></span><span>                                </span><span class="hs-comment">-- but excluding any RULES</span><span>
</span><span id="line-1203"></span><span>                                </span><span class="hs-comment">-- This is the IdSet that may be used if the Id is inlined</span><span>
</span><span id="line-1204"></span><span>
</span><span id="line-1205"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_weak"><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_weak"><span class="hs-identifier hs-var hs-var">nd_weak</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>       </span><span class="hs-comment">-- Binders of this Rec that are mentioned in nd_uds</span><span>
</span><span id="line-1206"></span><span>                                </span><span class="hs-comment">-- but are *not* in nd_inl.  These are the ones whose</span><span>
</span><span id="line-1207"></span><span>                                </span><span class="hs-comment">-- dependencies might not be respected by loop_breaker_nodes</span><span>
</span><span id="line-1208"></span><span>                                </span><span class="hs-comment">-- See Note [Weak loop breakers]</span><span>
</span><span id="line-1209"></span><span>
</span><span id="line-1210"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_active_rule_fvs"><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_active_rule_fvs"><span class="hs-identifier hs-var hs-var">nd_active_rule_fvs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>   </span><span class="hs-comment">-- Free variables of the RHS of active RULES</span><span>
</span><span id="line-1211"></span><span>
</span><span id="line-1212"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="nd_score"><span class="annot"><span class="annottext">Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var hs-var">nd_score</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span>
</span><span id="line-1213"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-1214"></span><span>
</span><span id="line-1215"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680867022"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1216"></span><span>   </span><span id="local-6989586621680867007"><span class="annot"><span class="annottext">ppr :: Details -&gt; SDoc
</span><a href="#local-6989586621680867007"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span id="local-6989586621680867006"><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ND&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span>
</span><span id="line-1217"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;bndr =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var hs-var">nd_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1218"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;uds =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_uds"><span class="hs-identifier hs-var hs-var">nd_uds</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1219"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;inl =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_inl"><span class="hs-identifier hs-var hs-var">nd_inl</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1220"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;weak =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_weak"><span class="hs-identifier hs-var hs-var">nd_weak</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1221"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rule =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_active_rule_fvs"><span class="hs-identifier hs-var hs-var">nd_active_rule_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1222"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;score =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NodeScore -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var hs-var">nd_score</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680867006"><span class="hs-identifier hs-var">nd</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1223"></span><span>             </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1224"></span><span>
</span><span id="line-1225"></span><span class="hs-comment">-- The NodeScore is compared lexicographically;</span><span>
</span><span id="line-1226"></span><span class="hs-comment">--      e.g. lower rank wins regardless of size</span><span>
</span><span id="line-1227"></span><span class="hs-keyword">type</span><span> </span><span id="NodeScore"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-var">NodeScore</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>     </span><span class="hs-comment">-- Rank: lower =&gt; more likely to be picked as loop breaker</span><span>
</span><span id="line-1228"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>     </span><span class="hs-comment">-- Size of rhs: higher =&gt; more likely to be picked as LB</span><span>
</span><span id="line-1229"></span><span>                           </span><span class="hs-comment">-- Maxes out at maxExprSize; we just use it to prioritise</span><span>
</span><span id="line-1230"></span><span>                           </span><span class="hs-comment">-- small functions</span><span>
</span><span id="line-1231"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Was it a loop breaker before?</span><span>
</span><span id="line-1232"></span><span>                           </span><span class="hs-comment">-- True =&gt; more likely to be picked</span><span>
</span><span id="line-1233"></span><span>                           </span><span class="hs-comment">-- Note [Loop breakers, node scoring, and stability]</span><span>
</span><span id="line-1234"></span><span>
</span><span id="line-1235"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#rank"><span class="hs-identifier hs-type">rank</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1236"></span><span id="rank"><span class="annot"><span class="annottext">rank :: NodeScore -&gt; JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#rank"><span class="hs-identifier hs-var hs-var">rank</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867003"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867003"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867003"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-1237"></span><span>
</span><span id="line-1238"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#makeNode"><span class="hs-identifier hs-type">makeNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ImpRuleEdges"><span class="hs-identifier hs-type">ImpRuleEdges</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-1239"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span>
</span><span id="line-1240"></span><span class="hs-comment">-- See Note [Recursive bindings: the grand plan]</span><span>
</span><span id="line-1241"></span><span id="makeNode"><span class="annot"><span class="annottext">makeNode :: OccEnv
-&gt; ImpRuleEdges
-&gt; VarSet
-&gt; (CoreBndr, CoreExpr)
-&gt; Node Unique Details
</span><a href="GHC.Core.Opt.OccurAnal.html#makeNode"><span class="hs-identifier hs-var hs-var">makeNode</span></a></span></span><span> </span><span id="local-6989586621680867002"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867002"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680867001"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867001"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span></span><span> </span><span id="local-6989586621680867000"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867000"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866999"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866998"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866998"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1242"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Details -&gt; Unique -&gt; [Unique] -&gt; Node Unique Details
forall key payload. payload -&gt; key -&gt; [key] -&gt; Node key payload
</span><a href="GHC.Data.Graph.Directed.html#DigraphNode"><span class="hs-identifier hs-var">DigraphNode</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680866996"><span class="hs-identifier hs-var">details</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unique
</span><a href="GHC.Types.Var.html#varUnique"><span class="hs-identifier hs-var">varUnique</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; [Unique]
forall elt. UniqSet elt -&gt; [Unique]
</span><a href="GHC.Types.Unique.Set.html#nonDetKeysUniqSet"><span class="hs-identifier hs-var">nonDetKeysUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866993"><span class="hs-identifier hs-var">node_fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1243"></span><span>    </span><span class="hs-comment">-- It's OK to use nonDetKeysUniqSet here as stronglyConnCompFromEdgedVerticesR</span><span>
</span><span id="line-1244"></span><span>    </span><span class="hs-comment">-- is still deterministic with edges in nondeterministic order as</span><span>
</span><span id="line-1245"></span><span>    </span><span class="hs-comment">-- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed.</span><span>
</span><span id="line-1246"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1247"></span><span>    </span><span id="local-6989586621680866996"><span class="annot"><span class="annottext">details :: Details
</span><a href="#local-6989586621680866996"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ND :: CoreBndr
-&gt; CoreExpr
-&gt; [CoreBndr]
-&gt; UsageDetails
-&gt; VarSet
-&gt; VarSet
-&gt; VarSet
-&gt; NodeScore
-&gt; Details
</span><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866989"><span class="hs-identifier hs-var">bndr'</span></a></span><span>
</span><span id="line-1248"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs :: CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var">nd_rhs</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866988"><span class="hs-identifier hs-var">rhs'</span></a></span><span>
</span><span id="line-1249"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs_bndrs :: [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs_bndrs"><span class="hs-identifier hs-var">nd_rhs_bndrs</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866987"><span class="hs-identifier hs-var">bndrs'</span></a></span><span>
</span><span id="line-1250"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_uds :: UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_uds"><span class="hs-identifier hs-var">nd_uds</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866986"><span class="hs-identifier hs-var">rhs_usage3</span></a></span><span>
</span><span id="line-1251"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_inl :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_inl"><span class="hs-identifier hs-var">nd_inl</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866985"><span class="hs-identifier hs-var">inl_fvs</span></a></span><span>
</span><span id="line-1252"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_weak :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_weak"><span class="hs-identifier hs-var">nd_weak</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866993"><span class="hs-identifier hs-var">node_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#minusVarSet"><span class="hs-operator hs-var">`minusVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866985"><span class="hs-identifier hs-var">inl_fvs</span></a></span><span>
</span><span id="line-1253"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_active_rule_fvs :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_active_rule_fvs"><span class="hs-identifier hs-var">nd_active_rule_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866983"><span class="hs-identifier hs-var">active_rule_fvs</span></a></span><span>
</span><span id="line-1254"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_score :: NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var">nd_score</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; NodeScore
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;makeNodeDetails&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1255"></span><span>
</span><span id="line-1256"></span><span>    </span><span id="local-6989586621680866989"><span class="annot"><span class="annottext">bndr' :: CoreBndr
</span><a href="#local-6989586621680866989"><span class="hs-identifier hs-var hs-var">bndr'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span>      </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866981"><span class="hs-identifier hs-var">unf'</span></a></span><span>
</span><span id="line-1257"></span><span>                 </span><span class="annot"><span class="annottext">CoreBndr -&gt; RuleInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdSpecialisation"><span class="hs-operator hs-var">`setIdSpecialisation`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; RuleInfo
</span><a href="GHC.Core.FVs.html#mkRuleInfo"><span class="hs-identifier hs-var">mkRuleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680866980"><span class="hs-identifier hs-var">rules'</span></a></span><span>
</span><span id="line-1258"></span><span>
</span><span id="line-1259"></span><span>    </span><span class="hs-comment">-- Get join point info from the *current* decision</span><span>
</span><span id="line-1260"></span><span>    </span><span class="hs-comment">-- We don't know what the new decision will be!</span><span>
</span><span id="line-1261"></span><span>    </span><span class="hs-comment">-- Using the old decision at least allows us to</span><span>
</span><span id="line-1262"></span><span>    </span><span class="hs-comment">-- preserve existing join point, even RULEs are added</span><span>
</span><span id="line-1263"></span><span>    </span><span class="hs-comment">-- See Note [Join points and unfoldings/rules]</span><span>
</span><span id="line-1264"></span><span>    </span><span id="local-6989586621680866979"><span class="annot"><span class="annottext">mb_join_arity :: Maybe JoinArity
</span><a href="#local-6989586621680866979"><span class="hs-identifier hs-var hs-var">mb_join_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1265"></span><span>
</span><span id="line-1266"></span><span>    </span><span class="hs-comment">-- Constructing the edges for the main Rec computation</span><span>
</span><span id="line-1267"></span><span>    </span><span class="hs-comment">-- See Note [Forming Rec groups]</span><span>
</span><span id="line-1268"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866977"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866977"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866976"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866976"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ([CoreBndr], CoreExpr)
forall b. Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectBinders"><span class="hs-identifier hs-var">collectBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866998"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1269"></span><span>    </span><span id="local-6989586621680866974"><span class="annot"><span class="annottext">rhs_env :: OccEnv
</span><a href="#local-6989586621680866974"><span class="hs-identifier hs-var hs-var">rhs_env</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#rhsCtxt"><span class="hs-identifier hs-var">rhsCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867002"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1270"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866973"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866973"><span class="hs-identifier hs-var">rhs_usage1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866987"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866987"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866972"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866972"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; [CoreBndr] -&gt; CoreExpr -&gt; (UsageDetails, [CoreBndr], CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866974"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866977"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866976"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1271"></span><span>    </span><span id="local-6989586621680866988"><span class="annot"><span class="annottext">rhs' :: CoreExpr
</span><a href="#local-6989586621680866988"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866987"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866972"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-1272"></span><span>    </span><span id="local-6989586621680866986"><span class="annot"><span class="annottext">rhs_usage3 :: UsageDetails
</span><a href="#local-6989586621680866986"><span class="hs-identifier hs-var hs-var">rhs_usage3</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [UsageDetails] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-var">andUDs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866973"><span class="hs-identifier hs-var">rhs_usage1</span></a></span><span> </span><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866968"><span class="hs-identifier hs-var">rule_uds</span></a></span><span>
</span><span id="line-1273"></span><span>                 </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866967"><span class="hs-identifier hs-var">unf_uds</span></a></span><span>
</span><span id="line-1274"></span><span>                   </span><span class="hs-comment">-- Note [Rules are extra RHSs]</span><span>
</span><span id="line-1275"></span><span>                   </span><span class="hs-comment">-- Note [Rule dependency info]</span><span>
</span><span id="line-1276"></span><span>    </span><span id="local-6989586621680866993"><span class="annot"><span class="annottext">node_fvs :: VarSet
</span><a href="#local-6989586621680866993"><span class="hs-identifier hs-var hs-var">node_fvs</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; UsageDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-var">udFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867000"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866986"><span class="hs-identifier hs-var">rhs_usage3</span></a></span><span>
</span><span id="line-1277"></span><span>
</span><span id="line-1278"></span><span>    </span><span class="hs-comment">-- Finding the free variables of the rules</span><span>
</span><span id="line-1279"></span><span>    </span><span id="local-6989586621680866965"><span class="annot"><span class="annottext">is_active :: Activation -&gt; Bool
</span><a href="#local-6989586621680866965"><span class="hs-identifier hs-var hs-var">is_active</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Activation -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_rule_act"><span class="hs-identifier hs-var hs-var">occ_rule_act</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680867002"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Activation"><span class="hs-identifier hs-type">Activation</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1280"></span><span>
</span><span id="line-1281"></span><span>    </span><span class="annot"><a href="#local-6989586621680866964"><span class="hs-identifier hs-type">rules_w_uds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1282"></span><span>    </span><span id="local-6989586621680866964"><span class="annot"><span class="annottext">rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680866964"><span class="hs-identifier hs-var hs-var">rules_w_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; Maybe JoinArity
-&gt; CoreBndr
-&gt; [(CoreRule, UsageDetails, UsageDetails)]
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRules"><span class="hs-identifier hs-var">occAnalRules</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866974"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866979"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1283"></span><span>
</span><span id="line-1284"></span><span>    </span><span id="local-6989586621680866980"><span class="annot"><span class="annottext">rules' :: [CoreRule]
</span><a href="#local-6989586621680866980"><span class="hs-identifier hs-var hs-var">rules'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreRule, UsageDetails, UsageDetails) -&gt; CoreRule)
-&gt; [(CoreRule, UsageDetails, UsageDetails)] -&gt; [CoreRule]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreRule, UsageDetails, UsageDetails) -&gt; CoreRule
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680866964"><span class="hs-identifier hs-var">rules_w_uds</span></a></span><span>
</span><span id="line-1285"></span><span>
</span><span id="line-1286"></span><span>    </span><span class="annot"><a href="#local-6989586621680866963"><span class="hs-identifier hs-type">rules_w_rhs_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Activation"><span class="hs-identifier hs-type">Activation</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Find the RHS fvs</span><span>
</span><span id="line-1287"></span><span>    </span><span id="local-6989586621680866963"><span class="annot"><span class="annottext">rules_w_rhs_fvs :: [(Activation, VarSet)]
</span><a href="#local-6989586621680866963"><span class="hs-identifier hs-var hs-var">rules_w_rhs_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([(Activation, VarSet)] -&gt; [(Activation, VarSet)])
-&gt; (VarSet -&gt; [(Activation, VarSet)] -&gt; [(Activation, VarSet)])
-&gt; Maybe VarSet
-&gt; [(Activation, VarSet)]
-&gt; [(Activation, VarSet)]
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[(Activation, VarSet)] -&gt; [(Activation, VarSet)]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680866960"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866960"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Activation
</span><a href="GHC.Types.Basic.html#AlwaysActive"><span class="hs-identifier hs-var">AlwaysActive</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866960"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(Activation, VarSet)
-&gt; [(Activation, VarSet)] -&gt; [(Activation, VarSet)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1288"></span><span>                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; CoreBndr -&gt; Maybe VarSet
forall a. VarEnv a -&gt; CoreBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680867001"><span class="hs-identifier hs-var">imp_rule_edges</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1289"></span><span>      </span><span class="hs-comment">-- See Note [Preventing loops due to imported functions rules]</span><span>
</span><span id="line-1290"></span><span>                      </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule -&gt; Activation
</span><a href="GHC.Core.html#ru_act"><span class="hs-identifier hs-var hs-var">ru_act</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866957"><span class="hs-identifier hs-var">rule</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; UsageDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-var">udFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867000"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866956"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1291"></span><span>                      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866957"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866957"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866956"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866956"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680866964"><span class="hs-identifier hs-var">rules_w_uds</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1292"></span><span>    </span><span id="local-6989586621680866968"><span class="annot"><span class="annottext">rule_uds :: [UsageDetails]
</span><a href="#local-6989586621680866968"><span class="hs-identifier hs-var hs-var">rule_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreRule, UsageDetails, UsageDetails) -&gt; UsageDetails)
-&gt; [(CoreRule, UsageDetails, UsageDetails)] -&gt; [UsageDetails]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866955"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866955"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866954"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866954"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866955"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866954"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreRule, UsageDetails, UsageDetails)]
</span><a href="#local-6989586621680866964"><span class="hs-identifier hs-var">rules_w_uds</span></a></span><span>
</span><span id="line-1293"></span><span>    </span><span id="local-6989586621680866983"><span class="annot"><span class="annottext">active_rule_fvs :: VarSet
</span><a href="#local-6989586621680866983"><span class="hs-identifier hs-var hs-var">active_rule_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VarSet] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSets"><span class="hs-identifier hs-var">unionVarSets</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866952"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866951"><span class="annot"><span class="annottext">Activation
</span><a href="#local-6989586621680866951"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680866952"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866952"><span class="hs-identifier hs-var">fvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Activation, VarSet)]
</span><a href="#local-6989586621680866963"><span class="hs-identifier hs-var">rules_w_rhs_fvs</span></a></span><span>
</span><span id="line-1294"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="#local-6989586621680866965"><span class="hs-identifier hs-var">is_active</span></a></span><span> </span><span class="annot"><span class="annottext">Activation
</span><a href="#local-6989586621680866951"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1295"></span><span>
</span><span id="line-1296"></span><span>    </span><span class="hs-comment">-- Finding the usage details of the INLINE pragma (if any)</span><span>
</span><span id="line-1297"></span><span>    </span><span id="local-6989586621680866950"><span class="annot"><span class="annottext">unf :: Unfolding
</span><a href="#local-6989586621680866950"><span class="hs-identifier hs-var hs-var">unf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866999"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-comment">-- realIdUnfolding: Ignore loop-breaker-ness</span><span>
</span><span id="line-1298"></span><span>                               </span><span class="hs-comment">-- here because that is what we are setting!</span><span>
</span><span id="line-1299"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866967"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866967"><span class="hs-identifier hs-var">unf_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866981"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866981"><span class="hs-identifier hs-var">unf'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Maybe JoinArity -&gt; Unfolding -&gt; (UsageDetails, Unfolding)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalUnfolding"><span class="hs-identifier hs-var">occAnalUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866974"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866979"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866950"><span class="hs-identifier hs-var">unf</span></a></span><span>
</span><span id="line-1300"></span><span>
</span><span id="line-1301"></span><span>    </span><span class="hs-comment">-- Find the &quot;nd_inl&quot; free vars; for the loop-breaker phase</span><span>
</span><span id="line-1302"></span><span>    </span><span class="hs-comment">-- These are the vars that would become free if the function</span><span>
</span><span id="line-1303"></span><span>    </span><span class="hs-comment">-- was inlinined; usually that means the RHS, unless the</span><span>
</span><span id="line-1304"></span><span>    </span><span class="hs-comment">-- unfolding is a stable one.</span><span>
</span><span id="line-1305"></span><span>    </span><span class="hs-comment">-- Note: We could do this only for functions with an *active* unfolding</span><span>
</span><span id="line-1306"></span><span>    </span><span class="hs-comment">--       (returning emptyVarSet for an inactive one), but is_active</span><span>
</span><span id="line-1307"></span><span>    </span><span class="hs-comment">--       isn't the right thing (it tells about RULE activation),</span><span>
</span><span id="line-1308"></span><span>    </span><span class="hs-comment">--       so we'd need more plumbing</span><span>
</span><span id="line-1309"></span><span>    </span><span id="local-6989586621680866985"><span class="annot"><span class="annottext">inl_fvs :: VarSet
</span><a href="#local-6989586621680866985"><span class="hs-identifier hs-var hs-var">inl_fvs</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#isStableUnfolding"><span class="hs-identifier hs-var">isStableUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866950"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; UsageDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-var">udFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867000"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866967"><span class="hs-identifier hs-var">unf_uds</span></a></span><span>
</span><span id="line-1310"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; UsageDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-var">udFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680867000"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866973"><span class="hs-identifier hs-var">rhs_usage1</span></a></span><span>
</span><span id="line-1311"></span><span>
</span><span id="line-1312"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#mkLoopBreakerNodes"><span class="hs-identifier hs-type">mkLoopBreakerNodes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>
</span><span id="line-1313"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-1314"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>   </span><span class="hs-comment">-- for BODY of let</span><span>
</span><span id="line-1315"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1316"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- adjusted</span><span>
</span><span id="line-1317"></span><span>                       </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#LetrecNode"><span class="hs-identifier hs-type">LetrecNode</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1318"></span><span class="hs-comment">-- Does four things</span><span>
</span><span id="line-1319"></span><span class="hs-comment">--   a) tag each binder with its occurrence info</span><span>
</span><span id="line-1320"></span><span class="hs-comment">--   b) add a NodeScore to each node</span><span>
</span><span id="line-1321"></span><span class="hs-comment">--   c) make a Node with the right dependency edges for</span><span>
</span><span id="line-1322"></span><span class="hs-comment">--      the loop-breaker SCC analysis</span><span>
</span><span id="line-1323"></span><span class="hs-comment">--   d) adjust each RHS's usage details according to</span><span>
</span><span id="line-1324"></span><span class="hs-comment">--      the binder's (new) shotness and join-point-hood</span><span>
</span><span id="line-1325"></span><span id="mkLoopBreakerNodes"><span class="annot"><span class="annottext">mkLoopBreakerNodes :: OccEnv
-&gt; TopLevelFlag
-&gt; VarSet
-&gt; UsageDetails
-&gt; [Details]
-&gt; (UsageDetails, [Node Unique Details])
</span><a href="GHC.Core.Opt.OccurAnal.html#mkLoopBreakerNodes"><span class="hs-identifier hs-var hs-var">mkLoopBreakerNodes</span></a></span></span><span> </span><span id="local-6989586621680866948"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866948"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866947"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866947"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680866946"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866946"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span> </span><span id="local-6989586621680866945"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866945"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span> </span><span id="local-6989586621680866944"><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680866944"><span class="hs-identifier hs-var">details_s</span></a></span></span><span>
</span><span id="line-1326"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866943"><span class="hs-identifier hs-var">final_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
-&gt; (Details -&gt; CoreBndr -&gt; Node Unique Details)
-&gt; [Details]
-&gt; [CoreBndr]
-&gt; [Node Unique Details]
forall a b c. String -&gt; (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="GHC.Utils.Misc.html#zipWithEqual"><span class="hs-identifier hs-var">zipWithEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mkLoopBreakerNodes&quot;</span></span><span> </span><span class="annot"><span class="annottext">Details -&gt; CoreBndr -&gt; Node Unique Details
</span><a href="#local-6989586621680866941"><span class="hs-identifier hs-var">mk_lb_node</span></a></span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680866944"><span class="hs-identifier hs-var">details_s</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866940"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1327"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1328"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866943"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866943"><span class="hs-identifier hs-var">final_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866940"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866940"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1329"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; UsageDetails
-&gt; [(CoreBndr, UsageDetails, [CoreBndr])]
-&gt; (UsageDetails, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#tagRecBinders"><span class="hs-identifier hs-var">tagRecBinders</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866947"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866945"><span class="hs-identifier hs-var">body_uds</span></a></span><span>
</span><span id="line-1330"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866938"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866937"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866936"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1331"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866938"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866938"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_uds :: Details -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_uds"><span class="hs-identifier hs-var">nd_uds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866937"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866937"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs_bndrs :: Details -&gt; [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs_bndrs"><span class="hs-identifier hs-var">nd_rhs_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866936"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866936"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1332"></span><span>                 </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680866944"><span class="hs-identifier hs-var">details_s</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1333"></span><span>
</span><span id="line-1334"></span><span>    </span><span id="local-6989586621680866941"><span class="annot"><span class="annottext">mk_lb_node :: Details -&gt; CoreBndr -&gt; Node Unique Details
</span><a href="#local-6989586621680866941"><span class="hs-identifier hs-var hs-var">mk_lb_node</span></a></span></span><span> </span><span id="local-6989586621680866935"><span class="annot"><span class="annottext">nd :: Details
</span><a href="#local-6989586621680866935"><span class="hs-identifier hs-var">nd</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866934"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866934"><span class="hs-identifier hs-var">old_bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_inl :: Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_inl"><span class="hs-identifier hs-var">nd_inl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866933"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866933"><span class="hs-identifier hs-var">inl_fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866932"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866932"><span class="hs-identifier hs-var">new_bndr</span></a></span></span><span>
</span><span id="line-1335"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Details -&gt; Unique -&gt; [Unique] -&gt; Node Unique Details
forall key payload. payload -&gt; key -&gt; [key] -&gt; Node key payload
</span><a href="GHC.Data.Graph.Directed.html#DigraphNode"><span class="hs-identifier hs-var">DigraphNode</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680866931"><span class="hs-identifier hs-var">nd'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unique
</span><a href="GHC.Types.Var.html#varUnique"><span class="hs-identifier hs-var">varUnique</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866934"><span class="hs-identifier hs-var">old_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; [Unique]
forall elt. UniqSet elt -&gt; [Unique]
</span><a href="GHC.Types.Unique.Set.html#nonDetKeysUniqSet"><span class="hs-identifier hs-var">nonDetKeysUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866930"><span class="hs-identifier hs-var">lb_deps</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1336"></span><span>              </span><span class="hs-comment">-- It's OK to use nonDetKeysUniqSet here as</span><span>
</span><span id="line-1337"></span><span>              </span><span class="hs-comment">-- stronglyConnCompFromEdgedVerticesR is still deterministic with edges</span><span>
</span><span id="line-1338"></span><span>              </span><span class="hs-comment">-- in nondeterministic order as explained in</span><span>
</span><span id="line-1339"></span><span>              </span><span class="hs-comment">-- Note [Deterministic SCC] in GHC.Data.Graph.Directed.</span><span>
</span><span id="line-1340"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1341"></span><span>        </span><span id="local-6989586621680866931"><span class="annot"><span class="annottext">nd' :: Details
</span><a href="#local-6989586621680866931"><span class="hs-identifier hs-var hs-var">nd'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680866935"><span class="hs-identifier hs-var">nd</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866932"><span class="hs-identifier hs-var">new_bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_score :: NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_score"><span class="hs-identifier hs-var">nd_score</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeScore
</span><a href="#local-6989586621680866929"><span class="hs-identifier hs-var">score</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1342"></span><span>        </span><span id="local-6989586621680866929"><span class="annot"><span class="annottext">score :: NodeScore
</span><a href="#local-6989586621680866929"><span class="hs-identifier hs-var hs-var">score</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreBndr -&gt; VarSet -&gt; Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nodeScore"><span class="hs-identifier hs-var">nodeScore</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866948"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866932"><span class="hs-identifier hs-var">new_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866930"><span class="hs-identifier hs-var">lb_deps</span></a></span><span> </span><span class="annot"><span class="annottext">Details
</span><a href="#local-6989586621680866935"><span class="hs-identifier hs-var">nd</span></a></span><span>
</span><span id="line-1343"></span><span>        </span><span id="local-6989586621680866930"><span class="annot"><span class="annottext">lb_deps :: VarSet
</span><a href="#local-6989586621680866930"><span class="hs-identifier hs-var hs-var">lb_deps</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#extendFvs_"><span class="hs-identifier hs-var">extendFvs_</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866926"><span class="hs-identifier hs-var">rule_fv_env</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866933"><span class="hs-identifier hs-var">inl_fvs</span></a></span><span>
</span><span id="line-1344"></span><span>
</span><span id="line-1345"></span><span>
</span><span id="line-1346"></span><span>    </span><span class="annot"><a href="#local-6989586621680866926"><span class="hs-identifier hs-type">rule_fv_env</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>
</span><span id="line-1347"></span><span>        </span><span class="hs-comment">-- Maps a variable f to the variables from this group</span><span>
</span><span id="line-1348"></span><span>        </span><span class="hs-comment">--      mentioned in RHS of active rules for f</span><span>
</span><span id="line-1349"></span><span>        </span><span class="hs-comment">-- Domain is *subset* of bound vars (others have no rule fvs)</span><span>
</span><span id="line-1350"></span><span>    </span><span id="local-6989586621680866926"><span class="annot"><span class="annottext">rule_fv_env :: ImpRuleEdges
</span><a href="#local-6989586621680866926"><span class="hs-identifier hs-var hs-var">rule_fv_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; ImpRuleEdges
</span><a href="GHC.Core.Opt.OccurAnal.html#transClosureFV"><span class="hs-identifier hs-var">transClosureFV</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(CoreBndr, VarSet)] -&gt; ImpRuleEdges
forall a. [(CoreBndr, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, VarSet)]
</span><a href="#local-6989586621680866923"><span class="hs-identifier hs-var">init_rule_fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1351"></span><span>    </span><span id="local-6989586621680866923"><span class="annot"><span class="annottext">init_rule_fvs :: [(CoreBndr, VarSet)]
</span><a href="#local-6989586621680866923"><span class="hs-identifier hs-var hs-var">init_rule_fvs</span></a></span></span><span>   </span><span class="hs-comment">-- See Note [Finding rule RHS free vars]</span><span>
</span><span id="line-1352"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866922"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866921"><span class="hs-identifier hs-var">trimmed_rule_fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1353"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866922"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866922"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_active_rule_fvs :: Details -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_active_rule_fvs"><span class="hs-identifier hs-var">nd_active_rule_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866920"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866920"><span class="hs-identifier hs-var">rule_fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Details]
</span><a href="#local-6989586621680866944"><span class="hs-identifier hs-var">details_s</span></a></span><span>
</span><span id="line-1354"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680866921"><span class="annot"><span class="annottext">trimmed_rule_fvs :: VarSet
</span><a href="#local-6989586621680866921"><span class="hs-identifier hs-var hs-var">trimmed_rule_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866920"><span class="hs-identifier hs-var">rule_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#intersectVarSet"><span class="hs-operator hs-var">`intersectVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866946"><span class="hs-identifier hs-var">bndr_set</span></a></span><span>
</span><span id="line-1355"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866921"><span class="hs-identifier hs-var">trimmed_rule_fvs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1356"></span><span>
</span><span id="line-1357"></span><span>
</span><span id="line-1358"></span><span class="hs-comment">------------------------------------------</span><span>
</span><span id="line-1359"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#nodeScore"><span class="hs-identifier hs-type">nodeScore</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-1360"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>        </span><span class="hs-comment">-- Binder with new occ-info</span><span>
</span><span id="line-1361"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>    </span><span class="hs-comment">-- Loop-breaker dependencies</span><span>
</span><span id="line-1362"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#Details"><span class="hs-identifier hs-type">Details</span></a></span><span>
</span><span id="line-1363"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span>
</span><span id="line-1364"></span><span id="nodeScore"><span class="annot"><span class="annottext">nodeScore :: OccEnv -&gt; CoreBndr -&gt; VarSet -&gt; Details -&gt; NodeScore
</span><a href="GHC.Core.Opt.OccurAnal.html#nodeScore"><span class="hs-identifier hs-var hs-var">nodeScore</span></a></span></span><span> </span><span id="local-6989586621680866918"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866918"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866917"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866917"><span class="hs-identifier hs-var">new_bndr</span></a></span></span><span> </span><span id="local-6989586621680866916"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866916"><span class="hs-identifier hs-var">lb_deps</span></a></span></span><span>
</span><span id="line-1365"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ND"><span class="hs-identifier hs-type">ND</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nd_bndr :: Details -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_bndr"><span class="hs-identifier hs-var">nd_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866915"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">nd_rhs :: Details -&gt; CoreExpr
</span><a href="GHC.Core.Opt.OccurAnal.html#nd_rhs"><span class="hs-identifier hs-var">nd_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866914"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866914"><span class="hs-identifier hs-var">bind_rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1366"></span><span>
</span><span id="line-1367"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- A type or coercion variable is never a loop breaker</span><span>
</span><span id="line-1368"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">100</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-1369"></span><span>
</span><span id="line-1370"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866916"><span class="hs-identifier hs-var">lb_deps</span></a></span><span>  </span><span class="hs-comment">-- Self-recursive things are great loop breakers</span><span>
</span><span id="line-1371"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>                   </span><span class="hs-comment">-- See Note [Self-recursion and loop breakers]</span><span>
</span><span id="line-1372"></span><span>
</span><span id="line-1373"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_unf_act"><span class="hs-identifier hs-var hs-var">occ_unf_act</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866918"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- A binder whose inlining is inactive (e.g. has</span><span>
</span><span id="line-1374"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>                   </span><span class="hs-comment">-- a NOINLINE pragma) makes a great loop breaker</span><span>
</span><span id="line-1375"></span><span>
</span><span id="line-1376"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTrivial"><span class="hs-identifier hs-var">exprIsTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866912"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1377"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">10</span></span><span>  </span><span class="hs-comment">-- Practically certain to be inlined</span><span>
</span><span id="line-1378"></span><span>    </span><span class="hs-comment">-- Used to have also: &amp;&amp; not (isExportedId bndr)</span><span>
</span><span id="line-1379"></span><span>    </span><span class="hs-comment">-- But I found this sometimes cost an extra iteration when we have</span><span>
</span><span id="line-1380"></span><span>    </span><span class="hs-comment">--      rec { d = (a,b); a = ...df...; b = ...df...; df = d }</span><span>
</span><span id="line-1381"></span><span>    </span><span class="hs-comment">-- where df is the exported dictionary. Then df makes a really</span><span>
</span><span id="line-1382"></span><span>    </span><span class="hs-comment">-- bad choice for loop breaker</span><span>
</span><span id="line-1383"></span><span>
</span><span id="line-1384"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_args :: Unfolding -&gt; [CoreExpr]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866908"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866908"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span>
</span><span id="line-1385"></span><span>    </span><span class="hs-comment">-- Never choose a DFun as a loop breaker</span><span>
</span><span id="line-1386"></span><span>    </span><span class="hs-comment">-- Note [DFuns should not be loop breakers]</span><span>
</span><span id="line-1387"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">9</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866908"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866905"><span class="hs-identifier hs-var">is_lb</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1388"></span><span>
</span><span id="line-1389"></span><span>    </span><span class="hs-comment">-- Data structures are more important than INLINE pragmas</span><span>
</span><span id="line-1390"></span><span>    </span><span class="hs-comment">-- so that dictionary/method recursion unravels</span><span>
</span><span id="line-1391"></span><span>
</span><span id="line-1392"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_guidance :: Unfolding -&gt; UnfoldingGuidance
</span><a href="GHC.Core.html#uf_guidance"><span class="hs-identifier hs-var">uf_guidance</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#UnfWhen"><span class="hs-identifier hs-type">UnfWhen</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span>
</span><span id="line-1393"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">6</span></span><span>
</span><span id="line-1394"></span><span>
</span><span id="line-1395"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
forall {b}. Expr b -&gt; Bool
</span><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866912"><span class="hs-identifier hs-var">rhs</span></a></span><span>   </span><span class="hs-comment">-- Data types help with cases:</span><span>
</span><span id="line-1396"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">5</span></span><span>       </span><span class="hs-comment">-- Note [Constructor applications]</span><span>
</span><span id="line-1397"></span><span>
</span><span id="line-1398"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#isStableUnfolding"><span class="hs-identifier hs-var">isStableUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span>
</span><span id="line-1399"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866900"><span class="hs-identifier hs-var">can_unfold</span></a></span><span>
</span><span id="line-1400"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">3</span></span><span>
</span><span id="line-1401"></span><span>
</span><span id="line-1402"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneOcc"><span class="hs-identifier hs-var">isOneOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866917"><span class="hs-identifier hs-var">new_bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1403"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">2</span></span><span>  </span><span class="hs-comment">-- Likely to be inlined</span><span>
</span><span id="line-1404"></span><span>
</span><span id="line-1405"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866900"><span class="hs-identifier hs-var">can_unfold</span></a></span><span>  </span><span class="hs-comment">-- The Id has some kind of unfolding</span><span>
</span><span id="line-1406"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var">mk_score</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1407"></span><span>
</span><span id="line-1408"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1409"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866905"><span class="hs-identifier hs-var">is_lb</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1410"></span><span>
</span><span id="line-1411"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1412"></span><span>    </span><span class="annot"><a href="#local-6989586621680866911"><span class="hs-identifier hs-type">mk_score</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span>
</span><span id="line-1413"></span><span>    </span><span id="local-6989586621680866911"><span class="annot"><span class="annottext">mk_score :: JoinArity -&gt; NodeScore
</span><a href="#local-6989586621680866911"><span class="hs-identifier hs-var hs-var">mk_score</span></a></span></span><span> </span><span id="local-6989586621680866898"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866898"><span class="hs-identifier hs-var">rank</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866898"><span class="hs-identifier hs-var">rank</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866897"><span class="hs-identifier hs-var">rhs_size</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866905"><span class="hs-identifier hs-var">is_lb</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1414"></span><span>
</span><span id="line-1415"></span><span>    </span><span class="hs-comment">-- is_lb: see Note [Loop breakers, node scoring, and stability]</span><span>
</span><span id="line-1416"></span><span>    </span><span id="local-6989586621680866905"><span class="annot"><span class="annottext">is_lb :: Bool
</span><a href="#local-6989586621680866905"><span class="hs-identifier hs-var hs-var">is_lb</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isStrongLoopBreaker"><span class="hs-identifier hs-var">isStrongLoopBreaker</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1417"></span><span>
</span><span id="line-1418"></span><span>    </span><span id="local-6989586621680866907"><span class="annot"><span class="annottext">old_unf :: Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var hs-var">old_unf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866915"><span class="hs-identifier hs-var">old_bndr</span></a></span><span>
</span><span id="line-1419"></span><span>    </span><span id="local-6989586621680866900"><span class="annot"><span class="annottext">can_unfold :: Bool
</span><a href="#local-6989586621680866900"><span class="hs-identifier hs-var hs-var">can_unfold</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#canUnfold"><span class="hs-identifier hs-var">canUnfold</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span>
</span><span id="line-1420"></span><span>    </span><span id="local-6989586621680866912"><span class="annot"><span class="annottext">rhs :: CoreExpr
</span><a href="#local-6989586621680866912"><span class="hs-identifier hs-var hs-var">rhs</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1421"></span><span>                   </span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866893"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866893"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: Unfolding -&gt; CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866891"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866891"><span class="hs-identifier hs-var">unf_rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1422"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866893"><span class="hs-identifier hs-var">src</span></a></span><span>
</span><span id="line-1423"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866891"><span class="hs-identifier hs-var">unf_rhs</span></a></span><span>
</span><span id="line-1424"></span><span>                   </span><span class="annot"><span class="annottext">Unfolding
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866914"><span class="hs-identifier hs-var">bind_rhs</span></a></span><span>
</span><span id="line-1425"></span><span>       </span><span class="hs-comment">-- 'bind_rhs' is irrelevant for inlining things with a stable unfolding</span><span>
</span><span id="line-1426"></span><span>    </span><span id="local-6989586621680866897"><span class="annot"><span class="annottext">rhs_size :: JoinArity
</span><a href="#local-6989586621680866897"><span class="hs-identifier hs-var hs-var">rhs_size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866907"><span class="hs-identifier hs-var">old_unf</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1427"></span><span>                 </span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_guidance :: Unfolding -&gt; UnfoldingGuidance
</span><a href="GHC.Core.html#uf_guidance"><span class="hs-identifier hs-var">uf_guidance</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866889"><span class="annot"><span class="annottext">UnfoldingGuidance
</span><a href="#local-6989586621680866889"><span class="hs-identifier hs-var">guidance</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1428"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#UnfIfGoodArgs"><span class="hs-identifier hs-type">UnfIfGoodArgs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ug_size :: UnfoldingGuidance -&gt; JoinArity
</span><a href="GHC.Core.html#ug_size"><span class="hs-identifier hs-var">ug_size</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866886"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866886"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnfoldingGuidance
</span><a href="#local-6989586621680866889"><span class="hs-identifier hs-var">guidance</span></a></span><span>
</span><span id="line-1429"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866886"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-1430"></span><span>                 </span><span class="annot"><span class="annottext">Unfolding
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#cheapExprSize"><span class="hs-identifier hs-var">cheapExprSize</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866912"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1431"></span><span>
</span><span id="line-1432"></span><span>
</span><span id="line-1433"></span><span>        </span><span class="hs-comment">-- Checking for a constructor application</span><span>
</span><span id="line-1434"></span><span>        </span><span class="hs-comment">-- Cheap and cheerful; the simplifier moves casts out of the way</span><span>
</span><span id="line-1435"></span><span>        </span><span class="hs-comment">-- The lambda case is important to spot x = /\a. C (f a)</span><span>
</span><span id="line-1436"></span><span>        </span><span class="hs-comment">-- which comes up when C is a dictionary constructor and</span><span>
</span><span id="line-1437"></span><span>        </span><span class="hs-comment">-- f is a default method.</span><span>
</span><span id="line-1438"></span><span>        </span><span class="hs-comment">-- Example: the instance for Show (ST s a) in GHC.ST</span><span>
</span><span id="line-1439"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1440"></span><span>        </span><span class="hs-comment">-- However we *also* treat (\x. C p q) as a con-app-like thing,</span><span>
</span><span id="line-1441"></span><span>        </span><span class="hs-comment">--      Note [Closure conversion]</span><span>
</span><span id="line-1442"></span><span>    </span><span id="local-6989586621680866901"><span class="annot"><span class="annottext">is_con_app :: Expr b -&gt; Bool
</span><a href="#local-6989586621680866901"><span class="hs-identifier hs-var hs-var">is_con_app</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680866883"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866883"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isConLikeId"><span class="hs-identifier hs-var">isConLikeId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866883"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1443"></span><span>    </span><span class="annot"><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680866880"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866880"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866880"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-1444"></span><span>    </span><span class="annot"><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680866878"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866878"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866878"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1445"></span><span>    </span><span class="annot"><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680866876"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866876"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866876"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1446"></span><span>    </span><span class="annot"><a href="#local-6989586621680866901"><span class="hs-identifier hs-var">is_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1447"></span><span>
</span><span id="line-1448"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#maxExprSize"><span class="hs-identifier hs-type">maxExprSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1449"></span><span id="maxExprSize"><span class="annot"><span class="annottext">maxExprSize :: JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#maxExprSize"><span class="hs-identifier hs-var hs-var">maxExprSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">20</span></span><span>  </span><span class="hs-comment">-- Rather arbitrary</span><span>
</span><span id="line-1450"></span><span>
</span><span id="line-1451"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#cheapExprSize"><span class="hs-identifier hs-type">cheapExprSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1452"></span><span class="hs-comment">-- Maxes out at maxExprSize</span><span>
</span><span id="line-1453"></span><span id="cheapExprSize"><span class="annot"><span class="annottext">cheapExprSize :: CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#cheapExprSize"><span class="hs-identifier hs-var hs-var">cheapExprSize</span></a></span></span><span> </span><span id="local-6989586621680866874"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866874"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-1454"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866873"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866874"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1455"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1456"></span><span>    </span><span id="local-6989586621680866873"><span class="annot"><span class="annottext">go :: JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866873"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680866864"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866864"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680866863"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866863"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866864"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#maxExprSize"><span class="hs-identifier hs-var">maxExprSize</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866864"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1457"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866864"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866863"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1458"></span><span>
</span><span id="line-1459"></span><span>    </span><span id="local-6989586621680866862"><span class="annot"><span class="annottext">go1 :: JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var hs-var">go1</span></a></span></span><span> </span><span id="local-6989586621680866861"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866861"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866861"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1460"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866860"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866860"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866860"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1461"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866858"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866858"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866858"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1462"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866856"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866856"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866856"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1463"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866854"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866854"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680866853"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866853"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866854"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866853"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1464"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866852"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866852"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680866850"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866850"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866852"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866850"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1465"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866849"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866849"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680866848"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866848"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680866847"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866847"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866873"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866849"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866848"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866847"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-1466"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866846"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866846"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680866845"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866845"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680866844"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866844"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1467"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866845"><span class="hs-identifier hs-var">b</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866846"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866844"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1468"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866873"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866846"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866844"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1469"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866843"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866843"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680866841"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680866841"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680866840"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866840"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [CoreExpr] -&gt; JoinArity
</span><a href="#local-6989586621680866839"><span class="hs-identifier hs-var">gos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866843"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866840"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBind -&gt; [CoreExpr]
forall b. Bind b -&gt; [Expr b]
</span><a href="GHC.Core.html#rhssOfBind"><span class="hs-identifier hs-var">rhssOfBind</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680866841"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1470"></span><span>    </span><span class="annot"><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span id="local-6989586621680866837"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866837"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680866835"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866835"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680866834"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866834"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [CoreExpr] -&gt; JoinArity
</span><a href="#local-6989586621680866839"><span class="hs-identifier hs-var">gos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866837"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866835"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Alt CoreBndr] -&gt; [CoreExpr]
forall b. [Alt b] -&gt; [Expr b]
</span><a href="GHC.Core.html#rhssOfAlts"><span class="hs-identifier hs-var">rhssOfAlts</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866834"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1471"></span><span>
</span><span id="line-1472"></span><span>    </span><span id="local-6989586621680866839"><span class="annot"><span class="annottext">gos :: JoinArity -&gt; [CoreExpr] -&gt; JoinArity
</span><a href="#local-6989586621680866839"><span class="hs-identifier hs-var hs-var">gos</span></a></span></span><span> </span><span id="local-6989586621680866832"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866832"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866832"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1473"></span><span>    </span><span class="annot"><a href="#local-6989586621680866839"><span class="hs-identifier hs-var">gos</span></a></span><span> </span><span id="local-6989586621680866831"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866831"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866830"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866830"><span class="hs-identifier hs-var">e</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866829"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866829"><span class="hs-identifier hs-var">es</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866831"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#maxExprSize"><span class="hs-identifier hs-var">maxExprSize</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866831"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1474"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [CoreExpr] -&gt; JoinArity
</span><a href="#local-6989586621680866839"><span class="hs-identifier hs-var">gos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680866862"><span class="hs-identifier hs-var">go1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866831"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866830"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866829"><span class="hs-identifier hs-var">es</span></a></span><span>
</span><span id="line-1475"></span><span>
</span><span id="line-1476"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#betterLB"><span class="hs-identifier hs-type">betterLB</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#NodeScore"><span class="hs-identifier hs-type">NodeScore</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1477"></span><span class="hs-comment">-- If  n1 `betterLB` n2  then choose n1 as the loop breaker</span><span>
</span><span id="line-1478"></span><span id="betterLB"><span class="annot"><span class="annottext">betterLB :: NodeScore -&gt; NodeScore -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#betterLB"><span class="hs-identifier hs-var hs-var">betterLB</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866828"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866828"><span class="hs-identifier hs-var">rank1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866827"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866827"><span class="hs-identifier hs-var">size1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866826"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866826"><span class="hs-identifier hs-var">lb1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866825"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866825"><span class="hs-identifier hs-var">rank2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866824"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866824"><span class="hs-identifier hs-var">size2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1479"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866828"><span class="hs-identifier hs-var">rank1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866825"><span class="hs-identifier hs-var">rank2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1480"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866828"><span class="hs-identifier hs-var">rank1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866825"><span class="hs-identifier hs-var">rank2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1481"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866827"><span class="hs-identifier hs-var">size1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866824"><span class="hs-identifier hs-var">size2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>   </span><span class="hs-comment">-- Make the bigger n2 into the loop breaker</span><span>
</span><span id="line-1482"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866827"><span class="hs-identifier hs-var">size1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866824"><span class="hs-identifier hs-var">size2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1483"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866826"><span class="hs-identifier hs-var">lb1</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>    </span><span class="hs-comment">-- Tie-break: if n1 was a loop breaker before, choose it</span><span>
</span><span id="line-1484"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>   </span><span class="hs-comment">-- See Note [Loop breakers, node scoring, and stability]</span><span>
</span><span id="line-1485"></span><span>
</span><span id="line-1486"></span><span class="hs-comment">{- Note [Self-recursion and loop breakers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we have
   rec { f = ...f...g...
       ; g = .....f...   }
then 'f' has to be a loop breaker anyway, so we may as well choose it
right away, so that g can inline freely.

This is really just a cheap hack. Consider
   rec { f = ...g...
       ; g = ..f..h...
      ;  h = ...f....}
Here f or g are better loop breakers than h; but we might accidentally
choose h.  Finding the minimal set of loop breakers is hard.

Note [Loop breakers, node scoring, and stability]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To choose a loop breaker, we give a NodeScore to each node in the SCC,
and pick the one with the best score (according to 'betterLB').

We need to be jolly careful (#12425, #12234) about the stability
of this choice. Suppose we have

    let rec { f = ...g...g...
            ; g = ...f...f... }
    in
    case x of
      True  -&gt; ...f..
      False -&gt; ..f...

In each iteration of the simplifier the occurrence analyser OccAnal
chooses a loop breaker. Suppose in iteration 1 it choose g as the loop
breaker. That means it is free to inline f.

Suppose that GHC decides to inline f in the branches of the case, but
(for some reason; eg it is not saturated) in the rhs of g. So we get

    let rec { f = ...g...g...
            ; g = ...f...f... }
    in
    case x of
      True  -&gt; ...g...g.....
      False -&gt; ..g..g....

Now suppose that, for some reason, in the next iteration the occurrence
analyser chooses f as the loop breaker, so it can freely inline g. And
again for some reason the simplifier inlines g at its calls in the case
branches, but not in the RHS of f. Then we get

    let rec { f = ...g...g...
            ; g = ...f...f... }
    in
    case x of
      True  -&gt; ...(...f...f...)...(...f..f..).....
      False -&gt; ..(...f...f...)...(..f..f...)....

You can see where this is going! Each iteration of the simplifier
doubles the number of calls to f or g. No wonder GHC is slow!

(In the particular example in comment:3 of #12425, f and g are the two
mutually recursive fmap instances for CondT and Result. They are both
marked INLINE which, oddly, is why they don't inline in each other's
RHS, because the call there is not saturated.)

The root cause is that we flip-flop on our choice of loop breaker. I
always thought it didn't matter, and indeed for any single iteration
to terminate, it doesn't matter. But when we iterate, it matters a
lot!!

So The Plan is this:
   If there is a tie, choose the node that
   was a loop breaker last time round

Hence the is_lb field of NodeScore

************************************************************************
*                                                                      *
                   Right hand sides
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1567"></span><span>
</span><span id="line-1568"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalRhs"><span class="hs-identifier hs-type">occAnalRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>
</span><span id="line-1569"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>   </span><span class="hs-comment">-- RHS</span><span>
</span><span id="line-1570"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1571"></span><span id="occAnalRhs"><span class="annot"><span class="annottext">occAnalRhs :: OccEnv -&gt; Maybe JoinArity -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRhs"><span class="hs-identifier hs-var hs-var">occAnalRhs</span></a></span></span><span> </span><span id="local-6989586621680866821"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866821"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866820"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866820"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680866819"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866819"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-1572"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; [CoreBndr] -&gt; CoreExpr -&gt; (UsageDetails, [CoreBndr], CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866821"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866818"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866817"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866816"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866816"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866815"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866815"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866814"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866814"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1573"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680866813"><span class="annot"><span class="annottext">rhs' :: CoreExpr
</span><a href="#local-6989586621680866813"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe JoinArity -&gt; [CoreBndr] -&gt; [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#markJoinOneShots"><span class="hs-identifier hs-var">markJoinOneShots</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866820"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866815"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866814"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-1574"></span><span>               </span><span class="hs-comment">-- For a /non-recursive/ join point we can mark all</span><span>
</span><span id="line-1575"></span><span>               </span><span class="hs-comment">-- its join-lambda as one-shot; and it's a good idea to do so</span><span>
</span><span id="line-1576"></span><span>
</span><span id="line-1577"></span><span>        </span><span class="hs-comment">-- Final adjustment</span><span>
</span><span id="line-1578"></span><span>        </span><span id="local-6989586621680866811"><span class="annot"><span class="annottext">rhs_usage :: UsageDetails
</span><a href="#local-6989586621680866811"><span class="hs-identifier hs-var hs-var">rhs_usage</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
-&gt; RecFlag -&gt; [CoreBndr] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#adjustRhsUsage"><span class="hs-identifier hs-var">adjustRhsUsage</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866820"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866815"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866816"><span class="hs-identifier hs-var">body_usage</span></a></span><span>
</span><span id="line-1579"></span><span>
</span><span id="line-1580"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866811"><span class="hs-identifier hs-var">rhs_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866813"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1581"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1582"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866818"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866818"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866817"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866817"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ([CoreBndr], CoreExpr)
forall b. Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectBinders"><span class="hs-identifier hs-var">collectBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866819"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1583"></span><span>
</span><span id="line-1584"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalUnfolding"><span class="hs-identifier hs-type">occAnalUnfolding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-1585"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>   </span><span class="hs-comment">-- See Note [Join points and unfoldings/rules]</span><span>
</span><span id="line-1586"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Unfolding"><span class="hs-identifier hs-type">Unfolding</span></a></span><span>
</span><span id="line-1587"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Unfolding"><span class="hs-identifier hs-type">Unfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1588"></span><span class="hs-comment">-- Occurrence-analyse a stable unfolding;</span><span>
</span><span id="line-1589"></span><span class="hs-comment">-- discard a non-stable one altogether.</span><span>
</span><span id="line-1590"></span><span id="occAnalUnfolding"><span class="annot"><span class="annottext">occAnalUnfolding :: OccEnv -&gt; Maybe JoinArity -&gt; Unfolding -&gt; (UsageDetails, Unfolding)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalUnfolding"><span class="hs-identifier hs-var hs-var">occAnalUnfolding</span></a></span></span><span> </span><span id="local-6989586621680866810"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866810"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866809"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866809"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680866808"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866808"><span class="hs-identifier hs-var">unf</span></a></span></span><span>
</span><span id="line-1591"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866808"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1592"></span><span>      </span><span id="local-6989586621680866807"><span class="annot"><span class="annottext">unf :: Unfolding
</span><a href="#local-6989586621680866807"><span class="hs-identifier hs-var">unf</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: Unfolding -&gt; CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866806"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866806"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866805"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866805"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1593"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866805"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866804"><span class="hs-identifier hs-var">usage</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866803"><span class="hs-identifier hs-var">unf'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1594"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866807"><span class="hs-identifier hs-var">unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1595"></span><span>        </span><span class="hs-keyword">where</span><span> </span><span class="hs-comment">-- For non-Stable unfoldings we leave them undisturbed, but</span><span>
</span><span id="line-1596"></span><span>              </span><span class="hs-comment">-- don't count their usage because the simplifier will discard them.</span><span>
</span><span id="line-1597"></span><span>              </span><span class="hs-comment">-- We leave them undisturbed because nodeScore uses their size info</span><span>
</span><span id="line-1598"></span><span>              </span><span class="hs-comment">-- to guide its decisions.  It's ok to leave un-substituted</span><span>
</span><span id="line-1599"></span><span>              </span><span class="hs-comment">-- expressions in the tree because all the variables that were in</span><span>
</span><span id="line-1600"></span><span>              </span><span class="hs-comment">-- scope remain in scope; there is no cloning etc.</span><span>
</span><span id="line-1601"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680866804"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866804"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866802"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866802"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Maybe JoinArity -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRhs"><span class="hs-identifier hs-var">occAnalRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866810"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866809"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866806"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1602"></span><span>
</span><span id="line-1603"></span><span>          </span><span id="local-6989586621680866803"><span class="annot"><span class="annottext">unf' :: Unfolding
</span><a href="#local-6989586621680866803"><span class="hs-identifier hs-var hs-var">unf'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#noBinderSwaps"><span class="hs-identifier hs-var">noBinderSwaps</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866810"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866807"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-comment">-- Note [Unfoldings and rules]</span><span>
</span><span id="line-1604"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866807"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866802"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1605"></span><span>
</span><span id="line-1606"></span><span>      </span><span id="local-6989586621680866800"><span class="annot"><span class="annottext">unf :: Unfolding
</span><a href="#local-6989586621680866800"><span class="hs-identifier hs-var">unf</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_bndrs :: Unfolding -&gt; [CoreBndr]
</span><a href="GHC.Core.html#df_bndrs"><span class="hs-identifier hs-var">df_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866798"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866798"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">df_args :: Unfolding -&gt; [CoreExpr]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866797"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866797"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1607"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866796"><span class="hs-identifier hs-var">final_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866800"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_args :: [CoreExpr]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866795"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1608"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-1609"></span><span>          </span><span id="local-6989586621680866794"><span class="annot"><span class="annottext">env' :: OccEnv
</span><a href="#local-6989586621680866794"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866810"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866798"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1610"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680866793"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866793"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866795"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866795"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-var">occAnalList</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866794"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866797"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1611"></span><span>          </span><span id="local-6989586621680866796"><span class="annot"><span class="annottext">final_usage :: UsageDetails
</span><a href="#local-6989586621680866796"><span class="hs-identifier hs-var hs-var">final_usage</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTail"><span class="hs-identifier hs-var">markAllManyNonTail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-identifier hs-var">delDetailsList</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866793"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866798"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1612"></span><span>
</span><span id="line-1613"></span><span>      </span><span id="local-6989586621680866789"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866789"><span class="hs-identifier hs-var">unf</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680866789"><span class="hs-identifier hs-var">unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1614"></span><span>
</span><span id="line-1615"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalRules"><span class="hs-identifier hs-type">occAnalRules</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-1616"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>  </span><span class="hs-comment">-- See Note [Join points and unfoldings/rules]</span><span>
</span><span id="line-1617"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>               </span><span class="hs-comment">-- Get rules from here</span><span>
</span><span id="line-1618"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- Each (non-built-in) rule</span><span>
</span><span id="line-1619"></span><span>                  </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>  </span><span class="hs-comment">-- Usage details for LHS</span><span>
</span><span id="line-1620"></span><span>                  </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Usage details for RHS</span><span>
</span><span id="line-1621"></span><span id="occAnalRules"><span class="annot"><span class="annottext">occAnalRules :: OccEnv
-&gt; Maybe JoinArity
-&gt; CoreBndr
-&gt; [(CoreRule, UsageDetails, UsageDetails)]
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRules"><span class="hs-identifier hs-var hs-var">occAnalRules</span></a></span></span><span> </span><span id="local-6989586621680866788"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866788"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866787"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866787"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680866786"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866786"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-1622"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; (CoreRule, UsageDetails, UsageDetails))
-&gt; [CoreRule] -&gt; [(CoreRule, UsageDetails, UsageDetails)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; (CoreRule, UsageDetails, UsageDetails)
</span><a href="#local-6989586621680866785"><span class="hs-identifier hs-var">occ_anal_rule</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreRule]
</span><a href="GHC.Types.Id.html#idCoreRules"><span class="hs-identifier hs-var">idCoreRules</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866786"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1623"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1624"></span><span>    </span><span id="local-6989586621680866785"><span class="annot"><span class="annottext">occ_anal_rule :: CoreRule -&gt; (CoreRule, UsageDetails, UsageDetails)
</span><a href="#local-6989586621680866785"><span class="hs-identifier hs-var hs-var">occ_anal_rule</span></a></span></span><span> </span><span id="local-6989586621680866783"><span class="annot"><span class="annottext">rule :: CoreRule
</span><a href="#local-6989586621680866783"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rule"><span class="hs-identifier hs-type">Rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: CoreRule -&gt; [CoreBndr]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866781"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866781"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_args :: CoreRule -&gt; [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866780"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866780"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreRule -&gt; CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866779"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866779"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1625"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866778"><span class="hs-identifier hs-var">rule'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866777"><span class="hs-identifier hs-var">lhs_uds'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866776"><span class="hs-identifier hs-var">rhs_uds'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1626"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1627"></span><span>        </span><span id="local-6989586621680866775"><span class="annot"><span class="annottext">env' :: OccEnv
</span><a href="#local-6989586621680866775"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866788"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866781"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1628"></span><span>        </span><span id="local-6989586621680866778"><span class="annot"><span class="annottext">rule' :: CoreRule
</span><a href="#local-6989586621680866778"><span class="hs-identifier hs-var hs-var">rule'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#noBinderSwaps"><span class="hs-identifier hs-var">noBinderSwaps</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866788"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866783"><span class="hs-identifier hs-var">rule</span></a></span><span>  </span><span class="hs-comment">-- Note [Unfoldings and rules]</span><span>
</span><span id="line-1629"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866783"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_args :: [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866774"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866773"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1630"></span><span>
</span><span id="line-1631"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680866772"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866772"><span class="hs-identifier hs-var">lhs_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866774"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866774"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-var">occAnalList</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866775"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866780"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1632"></span><span>        </span><span id="local-6989586621680866777"><span class="annot"><span class="annottext">lhs_uds' :: UsageDetails
</span><a href="#local-6989586621680866777"><span class="hs-identifier hs-var hs-var">lhs_uds'</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTail"><span class="hs-identifier hs-var">markAllManyNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1633"></span><span>                           </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866772"><span class="hs-identifier hs-var">lhs_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-operator hs-var">`delDetailsList`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866781"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1634"></span><span>
</span><span id="line-1635"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680866771"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866771"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866773"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866773"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866775"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866779"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1636"></span><span>                            </span><span class="hs-comment">-- Note [Rules are extra RHSs]</span><span>
</span><span id="line-1637"></span><span>                            </span><span class="hs-comment">-- Note [Rule dependency info]</span><span>
</span><span id="line-1638"></span><span>        </span><span id="local-6989586621680866776"><span class="annot"><span class="annottext">rhs_uds' :: UsageDetails
</span><a href="#local-6989586621680866776"><span class="hs-identifier hs-var hs-var">rhs_uds'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTailIf"><span class="hs-identifier hs-var">markAllNonTailIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866769"><span class="hs-identifier hs-var">exact_join</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1639"></span><span>                   </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllMany"><span class="hs-identifier hs-var">markAllMany</span></a></span><span>                             </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1640"></span><span>                   </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866771"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-operator hs-var">`delDetailsList`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866781"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1641"></span><span>
</span><span id="line-1642"></span><span>        </span><span id="local-6989586621680866769"><span class="annot"><span class="annottext">exact_join :: Bool
</span><a href="#local-6989586621680866769"><span class="hs-identifier hs-var hs-var">exact_join</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity -&gt; [CoreExpr] -&gt; Bool
forall a. Maybe JoinArity -&gt; [a] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#exactJoin"><span class="hs-identifier hs-var">exactJoin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866787"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866780"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1643"></span><span>                     </span><span class="hs-comment">-- See Note [Join points and unfoldings/rules]</span><span>
</span><span id="line-1644"></span><span>
</span><span id="line-1645"></span><span>    </span><span class="annot"><a href="#local-6989586621680866785"><span class="hs-identifier hs-var">occ_anal_rule</span></a></span><span> </span><span id="local-6989586621680866766"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866766"><span class="hs-identifier hs-var">other_rule</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680866766"><span class="hs-identifier hs-var">other_rule</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1646"></span><span>
</span><span id="line-1647"></span><span class="hs-comment">{- Note [Join point RHSs]
~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   x = e
   join j = Just x

We want to inline x into j right away, so we don't want to give
the join point a RhsCtxt (#14137).  It's not a huge deal, because
the FloatIn pass knows to float into join point RHSs; and the simplifier
does not float things out of join point RHSs.  But it's a simple, cheap
thing to do.  See #14137.

Note [Unfoldings and rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Generally unfoldings and rules are already occurrence-analysed, so we
don't want to reconstruct their trees; we just want to analyse them to
find how they use their free variables.

EXCEPT if there is a binder-swap going on, in which case we do want to
produce a new tree.

So we have a fast-path that keeps the old tree if the occ_bs_env is
empty.   This just saves a bit of allocation and reconstruction; not
a big deal.

Note [Cascading inlines]
~~~~~~~~~~~~~~~~~~~~~~~~
By default we use an rhsCtxt for the RHS of a binding.  This tells the
occ anal n that it's looking at an RHS, which has an effect in
occAnalApp.  In particular, for constructor applications, it makes
the arguments appear to have NoOccInfo, so that we don't inline into
them. Thus    x = f y
              k = Just x
we do not want to inline x.

But there's a problem.  Consider
     x1 = a0 : []
     x2 = a1 : x1
     x3 = a2 : x2
     g  = f x3
First time round, it looks as if x1 and x2 occur as an arg of a
let-bound constructor ==&gt; give them a many-occurrence.
But then x3 is inlined (unconditionally as it happens) and
next time round, x2 will be, and the next time round x1 will be
Result: multiple simplifier iterations.  Sigh.

So, when analysing the RHS of x3 we notice that x3 will itself
definitely inline the next time round, and so we analyse x3's rhs in
an ordinary context, not rhsCtxt.  Hence the &quot;certainly_inline&quot; stuff.

Annoyingly, we have to approximate GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally.
If (a) the RHS is expandable (see isExpandableApp in occAnalApp), and
   (b) certainly_inline says &quot;yes&quot; when preInlineUnconditionally says &quot;no&quot;
then the simplifier iterates indefinitely:
        x = f y
        k = Just x   -- We decide that k is 'certainly_inline'
        v = ...k...  -- but preInlineUnconditionally doesn't inline it
inline ==&gt;
        k = Just (f y)
        v = ...k...
float ==&gt;
        x1 = f y
        k = Just x1
        v = ...k...

This is worse than the slow cascade, so we only want to say &quot;certainly_inline&quot;
if it really is certain.  Look at the note with preInlineUnconditionally
for the various clauses.


************************************************************************
*                                                                      *
                Expressions
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1723"></span><span>
</span><span id="line-1724"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-type">occAnalList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1725"></span><span id="occAnalList"><span class="annot"><span class="annottext">occAnalList :: OccEnv -&gt; [CoreExpr] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-var hs-var">occAnalList</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1726"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-var">occAnalList</span></a></span><span> </span><span id="local-6989586621680866765"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866765"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866764"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866764"><span class="hs-identifier hs-var">e</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866763"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866763"><span class="hs-identifier hs-var">es</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866765"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866764"><span class="hs-identifier hs-var">e</span></a></span><span>      </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866762"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866762"><span class="hs-identifier hs-var">uds1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866761"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866761"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1727"></span><span>                         </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalList"><span class="hs-identifier hs-var">occAnalList</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866765"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866763"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866760"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866760"><span class="hs-identifier hs-var">uds2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866759"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866759"><span class="hs-identifier hs-var">es'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1728"></span><span>                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866762"><span class="hs-identifier hs-var">uds1</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866760"><span class="hs-identifier hs-var">uds2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866761"><span class="hs-identifier hs-var">e'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866759"><span class="hs-identifier hs-var">es'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1729"></span><span>
</span><span id="line-1730"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-type">occAnal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-1731"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1732"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>       </span><span class="hs-comment">-- Gives info only about the &quot;interesting&quot; Ids</span><span>
</span><span id="line-1733"></span><span>            </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1734"></span><span>
</span><span id="line-1735"></span><span id="occAnal"><span class="annot"><span class="annottext">occAnal :: OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var hs-var">occAnal</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span id="local-6989586621680866758"><span class="annot"><span class="annottext">expr :: CoreExpr
</span><a href="#local-6989586621680866758"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span>         </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866758"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1736"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span id="local-6989586621680866757"><span class="annot"><span class="annottext">expr :: CoreExpr
</span><a href="#local-6989586621680866757"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span>         </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866757"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1737"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866756"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866756"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866755"><span class="annot"><span class="annottext">expr :: CoreExpr
</span><a href="#local-6989586621680866755"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; (CoreExpr, [CoreExpr], [Tickish CoreBndr])
-&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-var">occAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866756"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866755"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1738"></span><span>    </span><span class="hs-comment">-- At one stage, I gathered the idRuleVars for the variable here too,</span><span>
</span><span id="line-1739"></span><span>    </span><span class="hs-comment">-- which in a way is the right thing to do.</span><span>
</span><span id="line-1740"></span><span>    </span><span class="hs-comment">-- But that went wrong right after specialisation, when</span><span>
</span><span id="line-1741"></span><span>    </span><span class="hs-comment">-- the *occurrences* of the overloaded function didn't have any</span><span>
</span><span id="line-1742"></span><span>    </span><span class="hs-comment">-- rules in them, so the *specialised* versions looked as if they</span><span>
</span><span id="line-1743"></span><span>    </span><span class="hs-comment">-- weren't used at all.</span><span>
</span><span id="line-1744"></span><span>
</span><span id="line-1745"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680866753"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866753"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1746"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var">addManyOccs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#coVarsOfCo"><span class="hs-identifier hs-var">coVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866753"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; CoreExpr
forall b. CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866753"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1747"></span><span>        </span><span class="hs-comment">-- See Note [Gather occurrences of coercion variables]</span><span>
</span><span id="line-1748"></span><span>
</span><span id="line-1749"></span><span class="hs-comment">{-
Note [Gather occurrences of coercion variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We need to gather info about what coercion variables appear, so that
we can sort them into the right place when doing dependency analysis.
-}</span><span>
</span><span id="line-1755"></span><span>
</span><span id="line-1756"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866751"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866751"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680866750"><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span></span><span> </span><span id="local-6989586621680866749"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866749"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1757"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#SourceNote"><span class="hs-identifier hs-type">SourceNote</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span>
</span><span id="line-1758"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866747"><span class="hs-identifier hs-var">usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866746"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1759"></span><span>                  </span><span class="hs-comment">-- SourceNotes are best-effort; so we just proceed as usual.</span><span>
</span><span id="line-1760"></span><span>                  </span><span class="hs-comment">-- If we drop a tick due to the issues described below it's</span><span>
</span><span id="line-1761"></span><span>                  </span><span class="hs-comment">-- not the end of the world.</span><span>
</span><span id="line-1762"></span><span>
</span><span id="line-1763"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; TickishScoping -&gt; Bool
forall id. Tickish id -&gt; TickishScoping -&gt; Bool
</span><a href="GHC.Core.html#tickishScopesLike"><span class="hs-operator hs-var">`tickishScopesLike`</span></a></span><span> </span><span class="annot"><span class="annottext">TickishScoping
</span><a href="GHC.Core.html#SoftScope"><span class="hs-identifier hs-var">SoftScope</span></a></span><span>
</span><span id="line-1764"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866747"><span class="hs-identifier hs-var">usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866746"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1765"></span><span>
</span><span id="line-1766"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-type">Breakpoint</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680866741"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866741"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span>
</span><span id="line-1767"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866740"><span class="hs-identifier hs-var">usage_lam</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOcc"><span class="hs-identifier hs-var">addManyOcc</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866741"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866746"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1768"></span><span>    </span><span class="hs-comment">-- never substitute for any of the Ids in a Breakpoint</span><span>
</span><span id="line-1769"></span><span>
</span><span id="line-1770"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1771"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866740"><span class="hs-identifier hs-var">usage_lam</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680866750"><span class="hs-identifier hs-var">tickish</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866746"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1772"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1773"></span><span>    </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span id="local-6989586621680866747"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866747"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680866746"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866746"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866751"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866749"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1774"></span><span>    </span><span class="hs-comment">-- for a non-soft tick scope, we can inline lambdas only</span><span>
</span><span id="line-1775"></span><span>    </span><span id="local-6989586621680866740"><span class="annot"><span class="annottext">usage_lam :: UsageDetails
</span><a href="#local-6989586621680866740"><span class="hs-identifier hs-var hs-var">usage_lam</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLam"><span class="hs-identifier hs-var">markAllInsideLam</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866747"><span class="hs-identifier hs-var">usage</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1776"></span><span>                  </span><span class="hs-comment">-- TODO There may be ways to make ticks and join points play</span><span>
</span><span id="line-1777"></span><span>                  </span><span class="hs-comment">-- nicer together, but right now there are problems:</span><span>
</span><span id="line-1778"></span><span>                  </span><span class="hs-comment">--   let j x = ... in tick&lt;t&gt; (j 1)</span><span>
</span><span id="line-1779"></span><span>                  </span><span class="hs-comment">-- Making j a join point may cause the simplifier to drop t</span><span>
</span><span id="line-1780"></span><span>                  </span><span class="hs-comment">-- (if the tick is put into the continuation). So we don't</span><span>
</span><span id="line-1781"></span><span>                  </span><span class="hs-comment">-- count j 1 as a tail call.</span><span>
</span><span id="line-1782"></span><span>                  </span><span class="hs-comment">-- See #14242.</span><span>
</span><span id="line-1783"></span><span>
</span><span id="line-1784"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866737"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866737"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680866736"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866736"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621680866735"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866735"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1785"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866737"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866736"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866734"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866734"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866733"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866733"><span class="hs-identifier hs-var">expr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1786"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680866732"><span class="annot"><span class="annottext">usage1 :: UsageDetails
</span><a href="#local-6989586621680866732"><span class="hs-identifier hs-var hs-var">usage1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTailIf"><span class="hs-identifier hs-var">markAllManyNonTailIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isRhsEnv"><span class="hs-identifier hs-var">isRhsEnv</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866737"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866734"><span class="hs-identifier hs-var">usage</span></a></span><span>
</span><span id="line-1787"></span><span>          </span><span class="hs-comment">-- usage1: if we see let x = y `cast` co</span><span>
</span><span id="line-1788"></span><span>          </span><span class="hs-comment">-- then mark y as 'Many' so that we don't</span><span>
</span><span id="line-1789"></span><span>          </span><span class="hs-comment">-- immediately inline y again.</span><span>
</span><span id="line-1790"></span><span>        </span><span id="local-6989586621680866729"><span class="annot"><span class="annottext">usage2 :: UsageDetails
</span><a href="#local-6989586621680866729"><span class="hs-identifier hs-var hs-var">usage2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var">addManyOccs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866732"><span class="hs-identifier hs-var">usage1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#coVarsOfCo"><span class="hs-identifier hs-var">coVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866735"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1791"></span><span>          </span><span class="hs-comment">-- usage2: see Note [Gather occurrences of coercion variables]</span><span>
</span><span id="line-1792"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866729"><span class="hs-identifier hs-var">usage2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoercionR -&gt; CoreExpr
forall b. Expr b -&gt; CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866733"><span class="hs-identifier hs-var">expr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866735"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1793"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-1794"></span><span>
</span><span id="line-1795"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866728"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866728"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866727"><span class="annot"><span class="annottext">app :: CoreExpr
</span><a href="#local-6989586621680866727"><span class="hs-identifier hs-var">app</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1796"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; (CoreExpr, [CoreExpr], [Tickish CoreBndr])
-&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-var">occAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866728"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool)
-&gt; CoreExpr -&gt; (CoreExpr, [CoreExpr], [Tickish CoreBndr])
forall b.
(Tickish CoreBndr -&gt; Bool)
-&gt; Expr b -&gt; (Expr b, [Expr b], [Tickish CoreBndr])
</span><a href="GHC.Core.html#collectArgsTicks"><span class="hs-identifier hs-var">collectArgsTicks</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866727"><span class="hs-identifier hs-var">app</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1797"></span><span>
</span><span id="line-1798"></span><span class="hs-comment">-- Ignore type variables altogether</span><span>
</span><span id="line-1799"></span><span class="hs-comment">--   (a) occurrences inside type lambdas only not marked as InsideLam</span><span>
</span><span id="line-1800"></span><span class="hs-comment">--   (b) type variables not in environment</span><span>
</span><span id="line-1801"></span><span>
</span><span id="line-1802"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866724"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866724"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680866723"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866723"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621680866722"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866722"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1803"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866723"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1804"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866724"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866722"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866721"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866721"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866720"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866720"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1805"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866721"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866723"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866720"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1806"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-1807"></span><span>
</span><span id="line-1808"></span><span class="hs-comment">-- For value lambdas we do a special hack.  Consider</span><span>
</span><span id="line-1809"></span><span class="hs-comment">--      (\x. \y. ...x...)</span><span>
</span><span id="line-1810"></span><span class="hs-comment">-- If we did nothing, x is used inside the \y, so would be marked</span><span>
</span><span id="line-1811"></span><span class="hs-comment">-- as dangerous to dup.  But in the common case where the abstraction</span><span>
</span><span id="line-1812"></span><span class="hs-comment">-- is applied to two arguments this is over-pessimistic.</span><span>
</span><span id="line-1813"></span><span class="hs-comment">-- So instead, we just mark each binder with its occurrence</span><span>
</span><span id="line-1814"></span><span class="hs-comment">-- info in the *body* of the multiple lambda.</span><span>
</span><span id="line-1815"></span><span class="hs-comment">-- Then, the simplifier is careful when partially applying lambdas.</span><span>
</span><span id="line-1816"></span><span>
</span><span id="line-1817"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866719"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866719"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866718"><span class="annot"><span class="annottext">expr :: CoreExpr
</span><a href="#local-6989586621680866718"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1818"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; [CoreBndr] -&gt; CoreExpr -&gt; (UsageDetails, [CoreBndr], CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866719"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866717"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866716"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866715"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866715"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866714"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866714"><span class="hs-identifier hs-var">tagged_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866713"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866713"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1819"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-1820"></span><span>        </span><span id="local-6989586621680866712"><span class="annot"><span class="annottext">expr' :: CoreExpr
</span><a href="#local-6989586621680866712"><span class="hs-identifier hs-var hs-var">expr'</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866714"><span class="hs-identifier hs-var">tagged_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866713"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-1821"></span><span>        </span><span id="local-6989586621680866711"><span class="annot"><span class="annottext">usage1 :: UsageDetails
</span><a href="#local-6989586621680866711"><span class="hs-identifier hs-var hs-var">usage1</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866715"><span class="hs-identifier hs-var">usage</span></a></span><span>
</span><span id="line-1822"></span><span>        </span><span id="local-6989586621680866709"><span class="annot"><span class="annottext">one_shot_gp :: Bool
</span><a href="#local-6989586621680866709"><span class="hs-identifier hs-var hs-var">one_shot_gp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isOneShotBndr"><span class="hs-identifier hs-var">isOneShotBndr</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866714"><span class="hs-identifier hs-var">tagged_bndrs</span></a></span><span>
</span><span id="line-1823"></span><span>        </span><span id="local-6989586621680866706"><span class="annot"><span class="annottext">final_usage :: UsageDetails
</span><a href="#local-6989586621680866706"><span class="hs-identifier hs-var hs-var">final_usage</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-var">markAllInsideLamIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866709"><span class="hs-identifier hs-var">one_shot_gp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866711"><span class="hs-identifier hs-var">usage1</span></a></span><span>
</span><span id="line-1824"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-1825"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866706"><span class="hs-identifier hs-var">final_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866712"><span class="hs-identifier hs-var">expr'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1826"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1827"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866717"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866717"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866716"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866716"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ([CoreBndr], CoreExpr)
forall b. Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectBinders"><span class="hs-identifier hs-var">collectBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866718"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1828"></span><span>
</span><span id="line-1829"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866704"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866704"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680866703"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866703"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680866702"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866702"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680866701"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680866701"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680866700"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866700"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1830"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; [Alt CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#scrutCtxt"><span class="hs-identifier hs-var">scrutCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866704"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866700"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866703"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866698"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866698"><span class="hs-identifier hs-var">scrut_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866697"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866697"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1831"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680866696"><span class="annot"><span class="annottext">alt_env :: OccEnv
</span><a href="#local-6989586621680866696"><span class="hs-identifier hs-var hs-var">alt_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreBndr -&gt; OccEnv -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addBndrSwap"><span class="hs-identifier hs-var">addBndrSwap</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866697"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866702"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">(OccEnv -&gt; OccEnv) -&gt; OccEnv -&gt; OccEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1832"></span><span>                  </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866704"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866702"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1833"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-1834"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(Alt CoreBndr -&gt; (UsageDetails, Alt CoreBndr))
-&gt; [Alt CoreBndr] -&gt; ([UsageDetails], [Alt CoreBndr])
forall a b c. (a -&gt; (b, c)) -&gt; [a] -&gt; ([b], [c])
</span><a href="GHC.Utils.Misc.html#mapAndUnzip"><span class="hs-identifier hs-var">mapAndUnzip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; Alt CoreBndr -&gt; (UsageDetails, Alt CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalAlt"><span class="hs-identifier hs-var">occAnalAlt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866696"><span class="hs-identifier hs-var">alt_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866700"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866690"><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866690"><span class="hs-identifier hs-var">alts_usage_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866689"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866689"><span class="hs-identifier hs-var">alts'</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1835"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-1836"></span><span>        </span><span id="local-6989586621680866687"><span class="annot"><span class="annottext">alts_usage :: UsageDetails
</span><a href="#local-6989586621680866687"><span class="hs-identifier hs-var hs-var">alts_usage</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [UsageDetails] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#orUDs"><span class="hs-identifier hs-var">orUDs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span> </span><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866690"><span class="hs-identifier hs-var">alts_usage_s</span></a></span><span>
</span><span id="line-1837"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680866685"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866685"><span class="hs-identifier hs-var">alts_usage1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866684"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866684"><span class="hs-identifier hs-var">tagged_bndr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinder"><span class="hs-identifier hs-var">tagLamBinder</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866687"><span class="hs-identifier hs-var">alts_usage</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866702"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1838"></span><span>        </span><span id="local-6989586621680866682"><span class="annot"><span class="annottext">total_usage :: UsageDetails
</span><a href="#local-6989586621680866682"><span class="hs-identifier hs-var hs-var">total_usage</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866698"><span class="hs-identifier hs-var">scrut_usage</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866685"><span class="hs-identifier hs-var">alts_usage1</span></a></span><span>
</span><span id="line-1839"></span><span>                        </span><span class="hs-comment">-- Alts can have tail calls, but the scrutinee can't</span><span>
</span><span id="line-1840"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-1841"></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866682"><span class="hs-identifier hs-var">total_usage</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
-&gt; (UsageDetails, CoreExpr) -&gt; (UsageDetails, CoreExpr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866682"><span class="hs-identifier hs-var">total_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreBndr -&gt; Type -&gt; [Alt CoreBndr] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866697"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866684"><span class="hs-identifier hs-var">tagged_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680866701"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866689"><span class="hs-identifier hs-var">alts'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-1842"></span><span>
</span><span id="line-1843"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span id="local-6989586621680866681"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866681"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680866680"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680866680"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680866679"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866679"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1844"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866681"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; [CoreBndr]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680866680"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1845"></span><span>                 </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866679"><span class="hs-identifier hs-var">body</span></a></span><span>                    </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866677"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866677"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866676"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866676"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1846"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; TopLevelFlag
-&gt; ImpRuleEdges
-&gt; CoreBind
-&gt; UsageDetails
-&gt; (UsageDetails, CoreProgram)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalBind"><span class="hs-identifier hs-var">occAnalBind</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866681"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span>
</span><span id="line-1847"></span><span>                     </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="GHC.Core.Opt.OccurAnal.html#noImpRuleEdges"><span class="hs-identifier hs-var">noImpRuleEdges</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680866680"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-1848"></span><span>                     </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866677"><span class="hs-identifier hs-var">body_usage</span></a></span><span>          </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866674"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866674"><span class="hs-identifier hs-var">final_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866673"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680866673"><span class="hs-identifier hs-var">new_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1849"></span><span>       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866674"><span class="hs-identifier hs-var">final_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreExpr -&gt; CoreExpr
forall b. [Bind b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLets"><span class="hs-identifier hs-var">mkLets</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680866673"><span class="hs-identifier hs-var">new_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866676"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-1850"></span><span>
</span><span id="line-1851"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-type">occAnalArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OneShots"><span class="hs-identifier hs-type">OneShots</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1852"></span><span id="occAnalArgs"><span class="annot"><span class="annottext">occAnalArgs :: OccEnv -&gt; [CoreExpr] -&gt; [OneShots] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var hs-var">occAnalArgs</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1853"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1854"></span><span>
</span><span id="line-1855"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var">occAnalArgs</span></a></span><span> </span><span id="local-6989586621680866670"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866670"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866669"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866669"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866668"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866668"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866667"><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866667"><span class="hs-identifier hs-var">one_shots</span></a></span></span><span>
</span><span id="line-1856"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
forall {b}. Expr b -&gt; Bool
</span><a href="GHC.Core.html#isTypeArg"><span class="hs-identifier hs-var">isTypeArg</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866669"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-1857"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; [OneShots] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var">occAnalArgs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866670"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866668"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866667"><span class="hs-identifier hs-var">one_shots</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866665"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866665"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866664"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866664"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1858"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866665"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866669"><span class="hs-identifier hs-var">arg</span></a></span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866664"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1859"></span><span>
</span><span id="line-1860"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1861"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [OneShots] -&gt; (OccEnv, [OneShots])
</span><a href="GHC.Core.Opt.OccurAnal.html#argCtxt"><span class="hs-identifier hs-var">argCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866670"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866667"><span class="hs-identifier hs-var">one_shots</span></a></span><span>           </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866662"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866662"><span class="hs-identifier hs-var">arg_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866661"><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866661"><span class="hs-identifier hs-var">one_shots'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1862"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866662"><span class="hs-identifier hs-var">arg_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866669"><span class="hs-identifier hs-var">arg</span></a></span><span>             </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866660"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866660"><span class="hs-identifier hs-var">uds1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866659"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866659"><span class="hs-identifier hs-var">arg'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1863"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; [OneShots] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var">occAnalArgs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866670"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866668"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866661"><span class="hs-identifier hs-var">one_shots'</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866658"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866658"><span class="hs-identifier hs-var">uds2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866657"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866657"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1864"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866660"><span class="hs-identifier hs-var">uds1</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866658"><span class="hs-identifier hs-var">uds2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866659"><span class="hs-identifier hs-var">arg'</span></a></span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866657"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-1865"></span><span>
</span><span id="line-1866"></span><span class="hs-comment">{-
Applications are dealt with specially because we want
the &quot;build hack&quot; to work.

Note [Arguments of let-bound constructors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
    f x = let y = expensive x in
          let z = (True,y) in
          (case z of {(p,q)-&gt;q}, case z of {(p,q)-&gt;q})
We feel free to duplicate the WHNF (True,y), but that means
that y may be duplicated thereby.

If we aren't careful we duplicate the (expensive x) call!
Constructors are rather like lambdas in this way.
-}</span><span>
</span><span id="line-1882"></span><span>
</span><span id="line-1883"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-type">occAnalApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-1884"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#Arg"><span class="hs-identifier hs-type">Arg</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1885"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1886"></span><span class="hs-comment">-- Naked variables (not applied) end up here too</span><span>
</span><span id="line-1887"></span><span id="occAnalApp"><span class="annot"><span class="annottext">occAnalApp :: OccEnv
-&gt; (CoreExpr, [CoreExpr], [Tickish CoreBndr])
-&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-var hs-var">occAnalApp</span></a></span></span><span> </span><span id="local-6989586621680866656"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866656"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680866655"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866655"><span class="hs-identifier hs-var">fun</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866654"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866654"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866653"><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866653"><span class="hs-identifier hs-var">ticks</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1888"></span><span>  </span><span class="hs-comment">-- Account for join arity of runRW# continuation</span><span>
</span><span id="line-1889"></span><span>  </span><span class="hs-comment">-- See Note [Simplification of runRW#]</span><span>
</span><span id="line-1890"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-1891"></span><span>  </span><span class="hs-comment">-- NB: Do not be tempted to make the next (Var fun, args, tick)</span><span>
</span><span id="line-1892"></span><span>  </span><span class="hs-comment">--     equation into an 'otherwise' clause for this equation</span><span>
</span><span id="line-1893"></span><span>  </span><span class="hs-comment">--     The former has a bang-pattern to occ-anal the args, and</span><span>
</span><span id="line-1894"></span><span>  </span><span class="hs-comment">--     we don't want to occ-anal them twice in the runRW# case!</span><span>
</span><span id="line-1895"></span><span>  </span><span class="hs-comment">--     This caused #18296</span><span>
</span><span id="line-1896"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866655"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier hs-var">runRWKey</span></a></span><span>
</span><span id="line-1897"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680866651"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866651"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866650"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866650"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866649"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866649"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866654"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1898"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866647"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866647"><span class="hs-identifier hs-var">usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866646"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866646"><span class="hs-identifier hs-var">arg'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; Maybe JoinArity -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalRhs"><span class="hs-identifier hs-var">occAnalRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866656"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; Maybe JoinArity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866649"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-1899"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866647"><span class="hs-identifier hs-var">usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier hs-var">mkTicks</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866653"><span class="hs-identifier hs-var">ticks</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr
forall b. CoreBndr -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866655"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866651"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866650"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866646"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1900"></span><span>
</span><span id="line-1901"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-var">occAnalApp</span></a></span><span> </span><span id="local-6989586621680866644"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680866643"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866643"><span class="hs-identifier hs-var">fun_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866642"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866642"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866641"><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866641"><span class="hs-identifier hs-var">ticks</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1902"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866640"><span class="hs-identifier hs-var">all_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier hs-var">mkTicks</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866641"><span class="hs-identifier hs-var">ticks</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866639"><span class="hs-identifier hs-var">fun'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866638"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1903"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1904"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866639"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866639"><span class="hs-identifier hs-var">fun'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866637"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866637"><span class="hs-identifier hs-var">fun_id'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreBndr -&gt; (CoreExpr, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupBndrSwap"><span class="hs-identifier hs-var">lookupBndrSwap</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866643"><span class="hs-identifier hs-var">fun_id</span></a></span><span>
</span><span id="line-1905"></span><span>
</span><span id="line-1906"></span><span>    </span><span id="local-6989586621680866635"><span class="annot"><span class="annottext">fun_uds :: UsageDetails
</span><a href="#local-6989586621680866635"><span class="hs-identifier hs-var hs-var">fun_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; InterestingCxt -&gt; JoinArity -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#mkOneOcc"><span class="hs-identifier hs-var">mkOneOcc</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866637"><span class="hs-identifier hs-var">fun_id'</span></a></span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866633"><span class="hs-identifier hs-var">int_cxt</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866632"><span class="hs-identifier hs-var">n_args</span></a></span><span>
</span><span id="line-1907"></span><span>       </span><span class="hs-comment">-- NB: fun_uds is computed for fun_id', not fun_id</span><span>
</span><span id="line-1908"></span><span>       </span><span class="hs-comment">-- See (BS1) in Note [The binder-swap substitution]</span><span>
</span><span id="line-1909"></span><span>
</span><span id="line-1910"></span><span>    </span><span id="local-6989586621680866640"><span class="annot"><span class="annottext">all_uds :: UsageDetails
</span><a href="#local-6989586621680866640"><span class="hs-identifier hs-var hs-var">all_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866635"><span class="hs-identifier hs-var">fun_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866631"><span class="hs-identifier hs-var">final_args_uds</span></a></span><span>
</span><span id="line-1911"></span><span>
</span><span id="line-1912"></span><span>    </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span id="local-6989586621680866630"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866630"><span class="hs-identifier hs-var">args_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866638"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866638"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; [OneShots] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var">occAnalArgs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866642"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866629"><span class="hs-identifier hs-var">one_shots</span></a></span><span>
</span><span id="line-1913"></span><span>    </span><span class="hs-glyph">!</span><span id="local-6989586621680866631"><span class="annot"><span class="annottext">final_args_uds :: UsageDetails
</span><a href="#local-6989586621680866631"><span class="hs-identifier hs-var hs-var">final_args_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span>                        </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1914"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-var">markAllInsideLamIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isRhsEnv"><span class="hs-identifier hs-var">isRhsEnv</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866628"><span class="hs-identifier hs-var">is_exp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1915"></span><span>                      </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866630"><span class="hs-identifier hs-var">args_uds</span></a></span><span>
</span><span id="line-1916"></span><span>       </span><span class="hs-comment">-- We mark the free vars of the argument of a constructor or PAP</span><span>
</span><span id="line-1917"></span><span>       </span><span class="hs-comment">-- as &quot;inside-lambda&quot;, if it is the RHS of a let(rec).</span><span>
</span><span id="line-1918"></span><span>       </span><span class="hs-comment">-- This means that nothing gets inlined into a constructor or PAP</span><span>
</span><span id="line-1919"></span><span>       </span><span class="hs-comment">-- argument position, which is what we want.  Typically those</span><span>
</span><span id="line-1920"></span><span>       </span><span class="hs-comment">-- constructor arguments are just variables, or trivial expressions.</span><span>
</span><span id="line-1921"></span><span>       </span><span class="hs-comment">-- We use inside-lam because it's like eta-expanding the PAP.</span><span>
</span><span id="line-1922"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-1923"></span><span>       </span><span class="hs-comment">-- This is the *whole point* of the isRhsEnv predicate</span><span>
</span><span id="line-1924"></span><span>       </span><span class="hs-comment">-- See Note [Arguments of let-bound constructors]</span><span>
</span><span id="line-1925"></span><span>
</span><span id="line-1926"></span><span>    </span><span id="local-6989586621680866627"><span class="annot"><span class="annottext">n_val_args :: JoinArity
</span><a href="#local-6989586621680866627"><span class="hs-identifier hs-var hs-var">n_val_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity
forall b. [Arg b] -&gt; JoinArity
</span><a href="GHC.Core.html#valArgCount"><span class="hs-identifier hs-var">valArgCount</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866642"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1927"></span><span>    </span><span id="local-6989586621680866632"><span class="annot"><span class="annottext">n_args :: JoinArity
</span><a href="#local-6989586621680866632"><span class="hs-identifier hs-var hs-var">n_args</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866642"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1928"></span><span>    </span><span id="local-6989586621680866633"><span class="annot"><span class="annottext">int_cxt :: InterestingCxt
</span><a href="#local-6989586621680866633"><span class="hs-identifier hs-var hs-var">int_cxt</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var hs-var">occ_encl</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1929"></span><span>                   </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccScrut"><span class="hs-identifier hs-var">OccScrut</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="GHC.Types.Basic.html#IsInteresting"><span class="hs-identifier hs-var">IsInteresting</span></a></span><span>
</span><span id="line-1930"></span><span>                   </span><span id="local-6989586621680866620"><span class="annot"><span class="annottext">OccEncl
</span><a href="#local-6989586621680866620"><span class="hs-identifier hs-var">_other</span></a></span></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866627"><span class="hs-identifier hs-var">n_val_args</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="GHC.Types.Basic.html#IsInteresting"><span class="hs-identifier hs-var">IsInteresting</span></a></span><span>
</span><span id="line-1931"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="GHC.Types.Basic.html#NotInteresting"><span class="hs-identifier hs-var">NotInteresting</span></a></span><span>
</span><span id="line-1932"></span><span>
</span><span id="line-1933"></span><span>    </span><span id="local-6989586621680866628"><span class="annot"><span class="annottext">is_exp :: Bool
</span><a href="#local-6989586621680866628"><span class="hs-identifier hs-var hs-var">is_exp</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="GHC.Core.Utils.html#isExpandableApp"><span class="hs-identifier hs-var">isExpandableApp</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866643"><span class="hs-identifier hs-var">fun_id</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866627"><span class="hs-identifier hs-var">n_val_args</span></a></span><span>
</span><span id="line-1934"></span><span>        </span><span class="hs-comment">-- See Note [CONLIKE pragma] in GHC.Types.Basic</span><span>
</span><span id="line-1935"></span><span>        </span><span class="hs-comment">-- The definition of is_exp should match that in GHC.Core.Opt.Simplify.prepareRhs</span><span>
</span><span id="line-1936"></span><span>
</span><span id="line-1937"></span><span>    </span><span id="local-6989586621680866629"><span class="annot"><span class="annottext">one_shots :: [OneShots]
</span><a href="#local-6989586621680866629"><span class="hs-identifier hs-var hs-var">one_shots</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; JoinArity -&gt; [OneShots]
</span><a href="GHC.Types.Demand.html#argsOneShots"><span class="hs-identifier hs-var">argsOneShots</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; StrictSig
</span><a href="GHC.Types.Id.html#idStrictness"><span class="hs-identifier hs-var">idStrictness</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866643"><span class="hs-identifier hs-var">fun_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866617"><span class="hs-identifier hs-var">guaranteed_val_args</span></a></span><span>
</span><span id="line-1938"></span><span>    </span><span id="local-6989586621680866617"><span class="annot"><span class="annottext">guaranteed_val_args :: JoinArity
</span><a href="#local-6989586621680866617"><span class="hs-identifier hs-var hs-var">guaranteed_val_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866627"><span class="hs-identifier hs-var">n_val_args</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OneShotInfo -&gt; Bool) -&gt; OneShots -&gt; OneShots
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneShotInfo"><span class="hs-identifier hs-var">isOneShotInfo</span></a></span><span>
</span><span id="line-1939"></span><span>                                                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var hs-var">occ_one_shots</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866644"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1940"></span><span>        </span><span class="hs-comment">-- See Note [Sources of one-shot information], bullet point A']</span><span>
</span><span id="line-1941"></span><span>
</span><span id="line-1942"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalApp"><span class="hs-identifier hs-var">occAnalApp</span></a></span><span> </span><span id="local-6989586621680866612"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866612"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866611"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866611"><span class="hs-identifier hs-var">fun</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866610"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866610"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866609"><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866609"><span class="hs-identifier hs-var">ticks</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1943"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866608"><span class="hs-identifier hs-var">fun_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-operator hs-var">`andUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866607"><span class="hs-identifier hs-var">args_uds</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-1944"></span><span>     </span><span class="annot"><span class="annottext">[Tickish CoreBndr] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier hs-var">mkTicks</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680866609"><span class="hs-identifier hs-var">ticks</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866606"><span class="hs-identifier hs-var">fun'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866605"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1945"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1946"></span><span>    </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span id="local-6989586621680866608"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866608"><span class="hs-identifier hs-var">fun_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866606"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866606"><span class="hs-identifier hs-var">fun'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addAppCtxt"><span class="hs-identifier hs-var">addAppCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866612"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866610"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866611"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-1947"></span><span>        </span><span class="hs-comment">-- The addAppCtxt is a bit cunning.  One iteration of the simplifier</span><span>
</span><span id="line-1948"></span><span>        </span><span class="hs-comment">-- often leaves behind beta redexs like</span><span>
</span><span id="line-1949"></span><span>        </span><span class="hs-comment">--      (\x y -&gt; e) a1 a2</span><span>
</span><span id="line-1950"></span><span>        </span><span class="hs-comment">-- Here we would like to mark x,y as one-shot, and treat the whole</span><span>
</span><span id="line-1951"></span><span>        </span><span class="hs-comment">-- thing much like a let.  We do this by pushing some True items</span><span>
</span><span id="line-1952"></span><span>        </span><span class="hs-comment">-- onto the context stack.</span><span>
</span><span id="line-1953"></span><span>    </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span id="local-6989586621680866607"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866607"><span class="hs-identifier hs-var">args_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866605"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866605"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreExpr] -&gt; [OneShots] -&gt; (UsageDetails, [CoreExpr])
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalArgs"><span class="hs-identifier hs-var">occAnalArgs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866612"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866610"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1954"></span><span>
</span><span id="line-1955"></span><span>
</span><span id="line-1956"></span><span class="hs-comment">{-
Note [Sources of one-shot information]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The occurrence analyser obtains one-shot-lambda information from two sources:

A:  Saturated applications:  eg   f e1 .. en

    In general, given a call (f e1 .. en) we can propagate one-shot info from
    f's strictness signature into e1 .. en, but /only/ if n is enough to
    saturate the strictness signature. A strictness signature like

          f :: C1(C1(L))LS

    means that *if f is applied to three arguments* then it will guarantee to
    call its first argument at most once, and to call the result of that at
    most once. But if f has fewer than three arguments, all bets are off; e.g.

          map (f (\x y. expensive) e2) xs

    Here the \x y abstraction may be called many times (once for each element of
    xs) so we should not mark x and y as one-shot. But if it was

          map (f (\x y. expensive) 3 2) xs

    then the first argument of f will be called at most once.

    The one-shot info, derived from f's strictness signature, is
    computed by 'argsOneShots', called in occAnalApp.

A': Non-obviously saturated applications: eg    build (f (\x y -&gt; expensive))
    where f is as above.

    In this case, f is only manifestly applied to one argument, so it does not
    look saturated. So by the previous point, we should not use its strictness
    signature to learn about the one-shotness of \x y. But in this case we can:
    build is fully applied, so we may use its strictness signature; and from
    that we learn that build calls its argument with two arguments *at most once*.

    So there is really only one call to f, and it will have three arguments. In
    that sense, f is saturated, and we may proceed as described above.

    Hence the computation of 'guaranteed_val_args' in occAnalApp, using
    '(occ_one_shots env)'.  See also #13227, comment:9

B:  Let-bindings:  eg   let f = \c. let ... in \n -&gt; blah
                        in (build f, build f)

    Propagate one-shot info from the demanand-info on 'f' to the
    lambdas in its RHS (which may not be syntactically at the top)

    This information must have come from a previous run of the demanand
    analyser.

Previously, the demand analyser would *also* set the one-shot information, but
that code was buggy (see #11770), so doing it only in on place, namely here, is
saner.

Note [OneShots]
~~~~~~~~~~~~~~~
When analysing an expression, the occ_one_shots argument contains information
about how the function is being used. The length of the list indicates
how many arguments will eventually be passed to the analysed expression,
and the OneShotInfo indicates whether this application is once or multiple times.

Example:

 Context of f                occ_one_shots when analysing f

 f 1 2                       [OneShot, OneShot]
 map (f 1)                   [OneShot, NoOneShotInfo]
 build f                     [OneShot, OneShot]
 f 1 2 `seq` f 2 1           [NoOneShotInfo, OneShot]

Note [Binders in case alternatives]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
    case x of y { (a,b) -&gt; f y }
We treat 'a', 'b' as dead, because they don't physically occur in the
case alternative.  (Indeed, a variable is dead iff it doesn't occur in
its scope in the output of OccAnal.)  It really helps to know when
binders are unused.  See esp the call to isDeadBinder in
Simplify.mkDupableAlt

In this example, though, the Simplifier will bring 'a' and 'b' back to
life, because it binds 'y' to (a,b) (imagine got inlined and
scrutinised y).
-}</span><span>
</span><span id="line-2043"></span><span>
</span><span id="line-2044"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-type">occAnalLamOrRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-2045"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2046"></span><span class="hs-comment">-- Tags the returned binders with their OccInfo, but does</span><span>
</span><span id="line-2047"></span><span class="hs-comment">-- not do any markInsideLam to the returned usage details</span><span>
</span><span id="line-2048"></span><span id="occAnalLamOrRhs"><span class="annot"><span class="annottext">occAnalLamOrRhs :: OccEnv
-&gt; [CoreBndr] -&gt; CoreExpr -&gt; (UsageDetails, [CoreBndr], CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var hs-var">occAnalLamOrRhs</span></a></span></span><span> </span><span id="local-6989586621680866603"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866603"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680866602"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866602"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-2049"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866603"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866602"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866601"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866601"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866600"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866600"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866601"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866600"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2050"></span><span>      </span><span class="hs-comment">-- RHS of thunk or nullary join point</span><span>
</span><span id="line-2051"></span><span>
</span><span id="line-2052"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span id="local-6989586621680866599"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866599"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866598"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866598"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866597"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866597"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866596"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866596"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-2053"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866598"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2054"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- Important: Keep the environment so that we don't inline into an RHS like</span><span>
</span><span id="line-2055"></span><span>    </span><span class="hs-comment">--   \(@ x) -&gt; C @x (f @x)</span><span>
</span><span id="line-2056"></span><span>    </span><span class="hs-comment">-- (see the beginning of Note [Cascading inlines]).</span><span>
</span><span id="line-2057"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv
-&gt; [CoreBndr] -&gt; CoreExpr -&gt; (UsageDetails, [CoreBndr], CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866599"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866597"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866596"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2058"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680866595"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866595"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866594"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866594"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866593"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866593"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866595"><span class="hs-identifier hs-var">body_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866598"><span class="hs-identifier hs-var">bndr</span></a></span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866594"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866593"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2059"></span><span>
</span><span id="line-2060"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalLamOrRhs"><span class="hs-identifier hs-var">occAnalLamOrRhs</span></a></span><span> </span><span id="local-6989586621680866592"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866592"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866591"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866591"><span class="hs-identifier hs-var">binders</span></a></span></span><span> </span><span id="local-6989586621680866590"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866590"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-2061"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866589"><span class="hs-identifier hs-var">env_body</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866590"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866588"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866588"><span class="hs-identifier hs-var">body_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866587"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866587"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-2062"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-2063"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680866586"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866586"><span class="hs-identifier hs-var">final_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866585"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866585"><span class="hs-identifier hs-var">tagged_binders</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; (UsageDetails, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinders"><span class="hs-identifier hs-var">tagLamBinders</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866588"><span class="hs-identifier hs-var">body_usage</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866583"><span class="hs-identifier hs-var">binders'</span></a></span><span>
</span><span id="line-2064"></span><span>                      </span><span class="hs-comment">-- Use binders' to put one-shot info on the lambdas</span><span>
</span><span id="line-2065"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-2066"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866586"><span class="hs-identifier hs-var">final_usage</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866585"><span class="hs-identifier hs-var">tagged_binders</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866587"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2067"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2068"></span><span>    </span><span id="local-6989586621680866582"><span class="annot"><span class="annottext">env1 :: OccEnv
</span><a href="#local-6989586621680866582"><span class="hs-identifier hs-var hs-var">env1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866592"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866591"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-2069"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866589"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866589"><span class="hs-identifier hs-var">env_body</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866583"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866583"><span class="hs-identifier hs-var">binders'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#oneShotGroup"><span class="hs-identifier hs-var">oneShotGroup</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866582"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866591"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-2070"></span><span>
</span><span id="line-2071"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#occAnalAlt"><span class="hs-identifier hs-type">occAnalAlt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2072"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Alt"><span class="hs-identifier hs-type">Alt</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-type">IdWithOccInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2073"></span><span id="occAnalAlt"><span class="annot"><span class="annottext">occAnalAlt :: OccEnv -&gt; Alt CoreBndr -&gt; (UsageDetails, Alt CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnalAlt"><span class="hs-identifier hs-var hs-var">occAnalAlt</span></a></span></span><span> </span><span id="local-6989586621680866578"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866578"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866577"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680866577"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866576"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866576"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866575"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866575"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2074"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreExpr -&gt; (UsageDetails, CoreExpr)
</span><a href="GHC.Core.Opt.OccurAnal.html#occAnal"><span class="hs-identifier hs-var">occAnal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866578"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-operator hs-var">`addInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866576"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866575"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866574"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866574"><span class="hs-identifier hs-var">rhs_usage1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866573"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866573"><span class="hs-identifier hs-var">rhs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-2075"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-2076"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680866572"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866572"><span class="hs-identifier hs-var">alt_usg</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866571"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866571"><span class="hs-identifier hs-var">tagged_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; (UsageDetails, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinders"><span class="hs-identifier hs-var">tagLamBinders</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866574"><span class="hs-identifier hs-var">rhs_usage1</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866576"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2077"></span><span>    </span><span class="hs-keyword">in</span><span>                          </span><span class="hs-comment">-- See Note [Binders in case alternatives]</span><span>
</span><span id="line-2078"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866572"><span class="hs-identifier hs-var">alt_usg</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680866577"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866571"><span class="hs-identifier hs-var">tagged_bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866573"><span class="hs-identifier hs-var">rhs1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2079"></span><span>
</span><span id="line-2080"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                    OccEnv
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2087"></span><span>
</span><span id="line-2088"></span><span class="hs-keyword">data</span><span> </span><span id="OccEnv"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-var">OccEnv</span></a></span></span><span>
</span><span id="line-2089"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="OccEnv"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-var">OccEnv</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="occ_encl"><span class="annot"><span class="annottext">OccEnv -&gt; OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var hs-var">occ_encl</span></a></span></span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEncl"><span class="hs-identifier hs-type">OccEncl</span></a></span><span>      </span><span class="hs-comment">-- Enclosing context information</span><span>
</span><span id="line-2090"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="occ_one_shots"><span class="annot"><span class="annottext">OccEnv -&gt; OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var hs-var">occ_one_shots</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OneShots"><span class="hs-identifier hs-type">OneShots</span></a></span><span>     </span><span class="hs-comment">-- See Note [OneShots]</span><span>
</span><span id="line-2091"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="occ_unf_act"><span class="annot"><span class="annottext">OccEnv -&gt; CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_unf_act"><span class="hs-identifier hs-var hs-var">occ_unf_act</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>          </span><span class="hs-comment">-- Which Id unfoldings are active</span><span>
</span><span id="line-2092"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="occ_rule_act"><span class="annot"><span class="annottext">OccEnv -&gt; Activation -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_rule_act"><span class="hs-identifier hs-var hs-var">occ_rule_act</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Activation"><span class="hs-identifier hs-type">Activation</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- Which rules are active</span><span>
</span><span id="line-2093"></span><span>             </span><span class="hs-comment">-- See Note [Finding rule RHS free vars]</span><span>
</span><span id="line-2094"></span><span>
</span><span id="line-2095"></span><span>           </span><span class="hs-comment">-- See Note [The binder-swap substitution]</span><span>
</span><span id="line-2096"></span><span>           </span><span class="hs-comment">-- If  x :-&gt; (y, co)  is in the env,</span><span>
</span><span id="line-2097"></span><span>           </span><span class="hs-comment">-- then please replace x by (y |&gt; sym mco)</span><span>
</span><span id="line-2098"></span><span>           </span><span class="hs-comment">-- Invariant of course: idType x = exprType (y |&gt; sym mco)</span><span>
</span><span id="line-2099"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="occ_bs_env"><span class="annot"><span class="annottext">OccEnv -&gt; VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var hs-var">occ_bs_env</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCoercion"><span class="hs-identifier hs-type">MCoercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2100"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="occ_bs_rng"><span class="annot"><span class="annottext">OccEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var hs-var">occ_bs_rng</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>   </span><span class="hs-comment">-- Vars free in the range of occ_bs_env</span><span>
</span><span id="line-2101"></span><span>                   </span><span class="hs-comment">-- Domain is Global and Local Ids</span><span>
</span><span id="line-2102"></span><span>                   </span><span class="hs-comment">-- Range is just Local Ids</span><span>
</span><span id="line-2103"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-2104"></span><span>
</span><span id="line-2105"></span><span>
</span><span id="line-2106"></span><span class="hs-comment">-----------------------------</span><span>
</span><span id="line-2107"></span><span class="hs-comment">-- OccEncl is used to control whether to inline into constructor arguments</span><span>
</span><span id="line-2108"></span><span class="hs-comment">-- For example:</span><span>
</span><span id="line-2109"></span><span class="hs-comment">--      x = (p,q)               -- Don't inline p or q</span><span>
</span><span id="line-2110"></span><span class="hs-comment">--      y = /\a -&gt; (p a, q a)   -- Still don't inline p or q</span><span>
</span><span id="line-2111"></span><span class="hs-comment">--      z = f (p,q)             -- Do inline p,q; it may make a rule fire</span><span>
</span><span id="line-2112"></span><span class="hs-comment">-- So OccEncl tells enough about the context to know what to do when</span><span>
</span><span id="line-2113"></span><span class="hs-comment">-- we encounter a constructor application or PAP.</span><span>
</span><span id="line-2114"></span><span class="hs-comment">--</span><span>
</span><span id="line-2115"></span><span class="hs-comment">-- OccScrut is used to set the &quot;interesting context&quot; field of OncOcc</span><span>
</span><span id="line-2116"></span><span>
</span><span id="line-2117"></span><span class="hs-keyword">data</span><span> </span><span id="OccEncl"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEncl"><span class="hs-identifier hs-var">OccEncl</span></a></span></span><span>
</span><span id="line-2118"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="OccRhs"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccRhs"><span class="hs-identifier hs-var">OccRhs</span></a></span></span><span>         </span><span class="hs-comment">-- RHS of let(rec), albeit perhaps inside a type lambda</span><span>
</span><span id="line-2119"></span><span>                   </span><span class="hs-comment">-- Don't inline into constructor args here</span><span>
</span><span id="line-2120"></span><span>
</span><span id="line-2121"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="OccScrut"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccScrut"><span class="hs-identifier hs-var">OccScrut</span></a></span></span><span>       </span><span class="hs-comment">-- Scrutintee of a case</span><span>
</span><span id="line-2122"></span><span>                   </span><span class="hs-comment">-- Can inline into constructor args</span><span>
</span><span id="line-2123"></span><span>
</span><span id="line-2124"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="OccVanilla"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span></span><span>     </span><span class="hs-comment">-- Argument of function, body of lambda, etc</span><span>
</span><span id="line-2125"></span><span>                   </span><span class="hs-comment">-- Do inline into constructor args here</span><span>
</span><span id="line-2126"></span><span>
</span><span id="line-2127"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680866563"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEncl"><span class="hs-identifier hs-type">OccEncl</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2128"></span><span>  </span><span id="local-6989586621680866562"><span class="annot"><span class="annottext">ppr :: OccEncl -&gt; SDoc
</span><a href="#local-6989586621680866562"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccRhs"><span class="hs-identifier hs-var">OccRhs</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;occRhs&quot;</span></span><span>
</span><span id="line-2129"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccScrut"><span class="hs-identifier hs-var">OccScrut</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;occScrut&quot;</span></span><span>
</span><span id="line-2130"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;occVanilla&quot;</span></span><span>
</span><span id="line-2131"></span><span>
</span><span id="line-2132"></span><span class="hs-comment">-- See note [OneShots]</span><span>
</span><span id="line-2133"></span><span class="hs-keyword">type</span><span> </span><span id="OneShots"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OneShots"><span class="hs-identifier hs-var">OneShots</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2134"></span><span>
</span><span id="line-2135"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#initOccEnv"><span class="hs-identifier hs-type">initOccEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2136"></span><span id="initOccEnv"><span class="annot"><span class="annottext">initOccEnv :: OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#initOccEnv"><span class="hs-identifier hs-var hs-var">initOccEnv</span></a></span></span><span>
</span><span id="line-2137"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv :: OccEncl
-&gt; OneShots
-&gt; (CoreBndr -&gt; Bool)
-&gt; (Activation -&gt; Bool)
-&gt; VarEnv (CoreBndr, MCoercion)
-&gt; VarSet
-&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span>
</span><span id="line-2138"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2139"></span><span>
</span><span id="line-2140"></span><span>                 </span><span class="hs-comment">-- To be conservative, we say that all</span><span>
</span><span id="line-2141"></span><span>                 </span><span class="hs-comment">-- inlines and rules are active</span><span>
</span><span id="line-2142"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_unf_act :: CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_unf_act"><span class="hs-identifier hs-var">occ_unf_act</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2143"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_rule_act :: Activation -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_rule_act"><span class="hs-identifier hs-var">occ_rule_act</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Activation
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2144"></span><span>
</span><span id="line-2145"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-2146"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_rng :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var">occ_bs_rng</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2147"></span><span>
</span><span id="line-2148"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#noBinderSwaps"><span class="hs-identifier hs-type">noBinderSwaps</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2149"></span><span id="noBinderSwaps"><span class="annot"><span class="annottext">noBinderSwaps :: OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#noBinderSwaps"><span class="hs-identifier hs-var hs-var">noBinderSwaps</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: OccEnv -&gt; VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866560"><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866560"><span class="hs-identifier hs-var">bs_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion) -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866560"><span class="hs-identifier hs-var">bs_env</span></a></span><span>
</span><span id="line-2150"></span><span>
</span><span id="line-2151"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#scrutCtxt"><span class="hs-identifier hs-type">scrutCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2152"></span><span id="scrutCtxt"><span class="annot"><span class="annottext">scrutCtxt :: OccEnv -&gt; [Alt CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#scrutCtxt"><span class="hs-identifier hs-var hs-var">scrutCtxt</span></a></span></span><span> </span><span id="local-6989586621680866558"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866558"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866557"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866557"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-2153"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866556"><span class="hs-identifier hs-var">interesting_alts</span></a></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866558"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccScrut"><span class="hs-identifier hs-var">OccScrut</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2154"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866558"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2155"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2156"></span><span>    </span><span id="local-6989586621680866556"><span class="annot"><span class="annottext">interesting_alts :: Bool
</span><a href="#local-6989586621680866556"><span class="hs-identifier hs-var hs-var">interesting_alts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680866557"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2157"></span><span>                         </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2158"></span><span>                         </span><span class="hs-special">[</span><span id="local-6989586621680866555"><span class="annot"><span class="annottext">Alt CoreBndr
</span><a href="#local-6989586621680866555"><span class="hs-identifier hs-var">alt</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Alt CoreBndr -&gt; Bool
forall a b. (AltCon, a, b) -&gt; Bool
</span><a href="GHC.Core.Utils.html#isDefaultAlt"><span class="hs-identifier hs-var">isDefaultAlt</span></a></span><span> </span><span class="annot"><span class="annottext">Alt CoreBndr
</span><a href="#local-6989586621680866555"><span class="hs-identifier hs-var">alt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2159"></span><span>                         </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2160"></span><span>     </span><span class="hs-comment">-- 'interesting_alts' is True if the case has at least one</span><span>
</span><span id="line-2161"></span><span>     </span><span class="hs-comment">-- non-default alternative.  That in turn influences</span><span>
</span><span id="line-2162"></span><span>     </span><span class="hs-comment">-- pre/postInlineUnconditionally.  Grep for &quot;occ_int_cxt&quot;!</span><span>
</span><span id="line-2163"></span><span>
</span><span id="line-2164"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#rhsCtxt"><span class="hs-identifier hs-type">rhsCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2165"></span><span id="rhsCtxt"><span class="annot"><span class="annottext">rhsCtxt :: OccEnv -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#rhsCtxt"><span class="hs-identifier hs-var hs-var">rhsCtxt</span></a></span></span><span> </span><span id="local-6989586621680866554"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866554"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866554"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccRhs"><span class="hs-identifier hs-var">OccRhs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2166"></span><span>
</span><span id="line-2167"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#argCtxt"><span class="hs-identifier hs-type">argCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OneShots"><span class="hs-identifier hs-type">OneShots</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OneShots"><span class="hs-identifier hs-type">OneShots</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2168"></span><span id="argCtxt"><span class="annot"><span class="annottext">argCtxt :: OccEnv -&gt; [OneShots] -&gt; (OccEnv, [OneShots])
</span><a href="GHC.Core.Opt.OccurAnal.html#argCtxt"><span class="hs-identifier hs-var hs-var">argCtxt</span></a></span></span><span> </span><span id="local-6989586621680866553"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866553"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2169"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866553"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2170"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#argCtxt"><span class="hs-identifier hs-var">argCtxt</span></a></span><span> </span><span id="local-6989586621680866552"><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866552"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866551"><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866551"><span class="hs-identifier hs-var">one_shots</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866550"><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866550"><span class="hs-identifier hs-var">one_shots_s</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2171"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866552"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866551"><span class="hs-identifier hs-var">one_shots</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[OneShots]
</span><a href="#local-6989586621680866550"><span class="hs-identifier hs-var">one_shots_s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2172"></span><span>
</span><span id="line-2173"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#isRhsEnv"><span class="hs-identifier hs-type">isRhsEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2174"></span><span id="isRhsEnv"><span class="annot"><span class="annottext">isRhsEnv :: OccEnv -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isRhsEnv"><span class="hs-identifier hs-var hs-var">isRhsEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEnv -&gt; OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866549"><span class="annot"><span class="annottext">OccEncl
</span><a href="#local-6989586621680866549"><span class="hs-identifier hs-var">cxt</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="#local-6989586621680866549"><span class="hs-identifier hs-var">cxt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2175"></span><span>                                          </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccRhs"><span class="hs-identifier hs-var">OccRhs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2176"></span><span>                                          </span><span class="annot"><span class="annottext">OccEncl
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2177"></span><span>
</span><span id="line-2178"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-identifier hs-type">addInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2179"></span><span class="hs-comment">-- See Note [The binder-swap substitution]</span><span>
</span><span id="line-2180"></span><span id="addInScope"><span class="annot"><span class="annottext">addInScope :: OccEnv -&gt; [CoreBndr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addInScope"><span class="hs-identifier hs-var hs-var">addInScope</span></a></span></span><span> </span><span id="local-6989586621680866548"><span class="annot"><span class="annottext">env :: OccEnv
</span><a href="#local-6989586621680866548"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: OccEnv -&gt; VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866547"><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866547"><span class="hs-identifier hs-var">swap_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_rng :: OccEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var">occ_bs_rng</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866546"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866546"><span class="hs-identifier hs-var">rng_vars</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866545"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866545"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-2181"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866546"><span class="hs-identifier hs-var">rng_vars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866545"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866548"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_rng :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var">occ_bs_rng</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2182"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866548"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866547"><span class="hs-identifier hs-var">swap_env</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
-&gt; [CoreBndr] -&gt; VarEnv (CoreBndr, MCoercion)
forall a. VarEnv a -&gt; [CoreBndr] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866545"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2183"></span><span>
</span><span id="line-2184"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#oneShotGroup"><span class="hs-identifier hs-type">oneShotGroup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2185"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2186"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2187"></span><span>        </span><span class="hs-comment">-- The result binders have one-shot-ness set that they might not have had originally.</span><span>
</span><span id="line-2188"></span><span>        </span><span class="hs-comment">-- This happens in (build (\c n -&gt; e)).  Here the occurrence analyser</span><span>
</span><span id="line-2189"></span><span>        </span><span class="hs-comment">-- linearity context knows that c,n are one-shot, and it records that fact in</span><span>
</span><span id="line-2190"></span><span>        </span><span class="hs-comment">-- the binder. This is useful to guide subsequent float-in/float-out transformations</span><span>
</span><span id="line-2191"></span><span>
</span><span id="line-2192"></span><span id="oneShotGroup"><span class="annot"><span class="annottext">oneShotGroup :: OccEnv -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#oneShotGroup"><span class="hs-identifier hs-var hs-var">oneShotGroup</span></a></span></span><span> </span><span id="local-6989586621680866543"><span class="annot"><span class="annottext">env :: OccEnv
</span><a href="#local-6989586621680866543"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OccEnv -&gt; OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866542"><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866542"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866541"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866541"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-2193"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneShots -&gt; [CoreBndr] -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="#local-6989586621680866540"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866542"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866541"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2194"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2195"></span><span>    </span><span id="local-6989586621680866540"><span class="annot"><span class="annottext">go :: OneShots -&gt; [CoreBndr] -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="#local-6989586621680866540"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680866539"><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866539"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680866538"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866538"><span class="hs-identifier hs-var">rev_bndrs</span></a></span></span><span>
</span><span id="line-2196"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866543"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866539"><span class="hs-identifier hs-var">ctxt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2197"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; [CoreBndr]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866538"><span class="hs-identifier hs-var">rev_bndrs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2198"></span><span>
</span><span id="line-2199"></span><span>    </span><span class="annot"><a href="#local-6989586621680866540"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680866536"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866536"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621680866535"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866535"><span class="hs-identifier hs-var">rev_bndrs</span></a></span></span><span>
</span><span id="line-2200"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866543"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_encl :: OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_encl"><span class="hs-identifier hs-var">occ_encl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEncl
</span><a href="GHC.Core.Opt.OccurAnal.html#OccVanilla"><span class="hs-identifier hs-var">OccVanilla</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2201"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; [CoreBndr]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866535"><span class="hs-identifier hs-var">rev_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866536"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2202"></span><span>
</span><span id="line-2203"></span><span>    </span><span class="annot"><a href="#local-6989586621680866540"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680866534"><span class="annot"><span class="annottext">ctxt :: OneShots
</span><a href="#local-6989586621680866534"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680866533"><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680866533"><span class="hs-identifier hs-var">one_shot</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680866532"><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866532"><span class="hs-identifier hs-var">ctxt'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866531"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866531"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680866530"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866530"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866529"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866529"><span class="hs-identifier hs-var">rev_bndrs</span></a></span></span><span>
</span><span id="line-2204"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866531"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneShots -&gt; [CoreBndr] -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="#local-6989586621680866540"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866532"><span class="hs-identifier hs-var">ctxt'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866530"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866528"><span class="hs-identifier hs-var">bndr'</span></a></span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866529"><span class="hs-identifier hs-var">rev_bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2205"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneShots -&gt; [CoreBndr] -&gt; [CoreBndr] -&gt; (OccEnv, [CoreBndr])
</span><a href="#local-6989586621680866540"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866534"><span class="hs-identifier hs-var">ctxt</span></a></span><span>  </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866530"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866531"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866529"><span class="hs-identifier hs-var">rev_bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2206"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2207"></span><span>        </span><span id="local-6989586621680866528"><span class="annot"><span class="annottext">bndr' :: CoreBndr
</span><a href="#local-6989586621680866528"><span class="hs-identifier hs-var hs-var">bndr'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OneShotInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#updOneShotInfo"><span class="hs-identifier hs-var">updOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866531"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680866533"><span class="hs-identifier hs-var">one_shot</span></a></span><span>
</span><span id="line-2208"></span><span>               </span><span class="hs-comment">-- Use updOneShotInfo, not setOneShotInfo, as pre-existing</span><span>
</span><span id="line-2209"></span><span>               </span><span class="hs-comment">-- one-shot info might be better than what we can infer, e.g.</span><span>
</span><span id="line-2210"></span><span>               </span><span class="hs-comment">-- due to explicit use of the magic 'oneShot' function.</span><span>
</span><span id="line-2211"></span><span>               </span><span class="hs-comment">-- See Note [The oneShot function]</span><span>
</span><span id="line-2212"></span><span>
</span><span id="line-2213"></span><span>
</span><span id="line-2214"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markJoinOneShots"><span class="hs-identifier hs-type">markJoinOneShots</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2215"></span><span class="hs-comment">-- Mark the lambdas of a non-recursive join point as one-shot.</span><span>
</span><span id="line-2216"></span><span class="hs-comment">-- This is good to prevent gratuitous float-out etc</span><span>
</span><span id="line-2217"></span><span id="markJoinOneShots"><span class="annot"><span class="annottext">markJoinOneShots :: Maybe JoinArity -&gt; [CoreBndr] -&gt; [CoreBndr]
</span><a href="GHC.Core.Opt.OccurAnal.html#markJoinOneShots"><span class="hs-identifier hs-var hs-var">markJoinOneShots</span></a></span></span><span> </span><span id="local-6989586621680866526"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866526"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680866525"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866525"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-2218"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866526"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2219"></span><span>      </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866525"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2220"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680866524"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866524"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [CoreBndr] -&gt; [CoreBndr]
forall {t}. (Eq t, Num t) =&gt; t -&gt; [CoreBndr] -&gt; [CoreBndr]
</span><a href="#local-6989586621680866523"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866524"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866525"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2221"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2222"></span><span>   </span><span id="local-6989586621680866523"><span class="annot"><span class="annottext">go :: t -&gt; [CoreBndr] -&gt; [CoreBndr]
</span><a href="#local-6989586621680866523"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621680866516"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866516"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866516"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2223"></span><span>   </span><span class="annot"><a href="#local-6989586621680866523"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- This can legitimately happen.</span><span>
</span><span id="line-2224"></span><span>                    </span><span class="hs-comment">-- e.g.    let j = case ... in j True</span><span>
</span><span id="line-2225"></span><span>                    </span><span class="hs-comment">-- This will become an arity-1 join point after the</span><span>
</span><span id="line-2226"></span><span>                    </span><span class="hs-comment">-- simplifier has eta-expanded it; but it may not have</span><span>
</span><span id="line-2227"></span><span>                    </span><span class="hs-comment">-- enough lambdas /yet/. (Lint checks that JoinIds do</span><span>
</span><span id="line-2228"></span><span>                    </span><span class="hs-comment">-- have enough lambdas.)</span><span>
</span><span id="line-2229"></span><span>   </span><span class="annot"><a href="#local-6989586621680866523"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680866515"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680866515"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866514"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866514"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680866513"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866513"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866512"><span class="hs-identifier hs-var">b'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">t -&gt; [CoreBndr] -&gt; [CoreBndr]
</span><a href="#local-6989586621680866523"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680866515"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866513"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-2230"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-2231"></span><span>       </span><span id="local-6989586621680866512"><span class="annot"><span class="annottext">b' :: CoreBndr
</span><a href="#local-6989586621680866512"><span class="hs-identifier hs-var hs-var">b'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866514"><span class="hs-identifier hs-var">b</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setOneShotLambda"><span class="hs-identifier hs-var">setOneShotLambda</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866514"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-2232"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866514"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-2233"></span><span>
</span><span id="line-2234"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addAppCtxt"><span class="hs-identifier hs-type">addAppCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#Arg"><span class="hs-identifier hs-type">Arg</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2235"></span><span id="addAppCtxt"><span class="annot"><span class="annottext">addAppCtxt :: OccEnv -&gt; [CoreExpr] -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addAppCtxt"><span class="hs-identifier hs-var hs-var">addAppCtxt</span></a></span></span><span> </span><span id="local-6989586621680866510"><span class="annot"><span class="annottext">env :: OccEnv
</span><a href="#local-6989586621680866510"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OccEnv -&gt; OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866509"><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866509"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866508"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866508"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-2236"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866510"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_one_shots :: OneShots
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_one_shots"><span class="hs-identifier hs-var">occ_one_shots</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; OneShotInfo -&gt; OneShots
forall a. JoinArity -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity
forall b. [Arg b] -&gt; JoinArity
</span><a href="GHC.Core.html#valArgCount"><span class="hs-identifier hs-var">valArgCount</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866508"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="GHC.Types.Basic.html#OneShotLam"><span class="hs-identifier hs-var">OneShotLam</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots -&gt; OneShots -&gt; OneShots
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">OneShots
</span><a href="#local-6989586621680866509"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2237"></span><span>
</span><span id="line-2238"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#transClosureFV"><span class="hs-identifier hs-type">transClosureFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2239"></span><span class="hs-comment">-- If (f,g), (g,h) are in the input, then (f,h) is in the output</span><span>
</span><span id="line-2240"></span><span class="hs-comment">--                                   as well as (f,g), (g,h)</span><span>
</span><span id="line-2241"></span><span id="transClosureFV"><span class="annot"><span class="annottext">transClosureFV :: ImpRuleEdges -&gt; ImpRuleEdges
</span><a href="GHC.Core.Opt.OccurAnal.html#transClosureFV"><span class="hs-identifier hs-var hs-var">transClosureFV</span></a></span></span><span> </span><span id="local-6989586621680866505"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866505"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-2242"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866504"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866505"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-2243"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; ImpRuleEdges
</span><a href="GHC.Core.Opt.OccurAnal.html#transClosureFV"><span class="hs-identifier hs-var">transClosureFV</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Unique, VarSet)] -&gt; ImpRuleEdges
forall elt key. [(Unique, elt)] -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#listToUFM_Directly"><span class="hs-identifier hs-var">listToUFM_Directly</span></a></span><span> </span><span class="annot"><span class="annottext">[(Unique, VarSet)]
</span><a href="#local-6989586621680866502"><span class="hs-identifier hs-var">new_fv_list</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2244"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2245"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866504"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866504"><span class="hs-identifier hs-var">no_change</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866502"><span class="annot"><span class="annottext">[(Unique, VarSet)]
</span><a href="#local-6989586621680866502"><span class="hs-identifier hs-var">new_fv_list</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; (Unique, VarSet) -&gt; (Bool, (Unique, VarSet)))
-&gt; Bool -&gt; [(Unique, VarSet)] -&gt; (Bool, [(Unique, VarSet)])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (Unique, VarSet) -&gt; (Bool, (Unique, VarSet))
forall {a}. Bool -&gt; (a, VarSet) -&gt; (Bool, (a, VarSet))
</span><a href="#local-6989586621680866498"><span class="hs-identifier hs-var">bump</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; [(Unique, VarSet)]
forall key elt. UniqFM key elt -&gt; [(Unique, elt)]
</span><a href="GHC.Types.Unique.FM.html#nonDetUFMToList"><span class="hs-identifier hs-var">nonDetUFMToList</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866505"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2246"></span><span>      </span><span class="hs-comment">-- It's OK to use nonDetUFMToList here because we'll forget the</span><span>
</span><span id="line-2247"></span><span>      </span><span class="hs-comment">-- ordering by creating a new set with listToUFM</span><span>
</span><span id="line-2248"></span><span>    </span><span id="local-6989586621680866498"><span class="annot"><span class="annottext">bump :: Bool -&gt; (a, VarSet) -&gt; (Bool, (a, VarSet))
</span><a href="#local-6989586621680866498"><span class="hs-identifier hs-var hs-var">bump</span></a></span></span><span> </span><span id="local-6989586621680866496"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866496"><span class="hs-identifier hs-var">no_change</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866495"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680866495"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680866494"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866494"><span class="hs-identifier hs-var">fvs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2249"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866493"><span class="hs-identifier hs-var">no_change_here</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866496"><span class="hs-identifier hs-var">no_change</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680866495"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866494"><span class="hs-identifier hs-var">fvs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2250"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680866495"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866492"><span class="hs-identifier hs-var">new_fvs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2251"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2252"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680866492"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866492"><span class="hs-identifier hs-var">new_fvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866493"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866493"><span class="hs-identifier hs-var">no_change_here</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; VarSet -&gt; (VarSet, Bool)
</span><a href="GHC.Core.Opt.OccurAnal.html#extendFvs"><span class="hs-identifier hs-var">extendFvs</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866505"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866494"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-2253"></span><span>
</span><span id="line-2254"></span><span class="hs-comment">-------------</span><span>
</span><span id="line-2255"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#extendFvs_"><span class="hs-identifier hs-type">extendFvs_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2256"></span><span id="extendFvs_"><span class="annot"><span class="annottext">extendFvs_ :: ImpRuleEdges -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#extendFvs_"><span class="hs-identifier hs-var hs-var">extendFvs_</span></a></span></span><span> </span><span id="local-6989586621680866490"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866490"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866489"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866489"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet, Bool) -&gt; VarSet
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; VarSet -&gt; (VarSet, Bool)
</span><a href="GHC.Core.Opt.OccurAnal.html#extendFvs"><span class="hs-identifier hs-var">extendFvs</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866490"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866489"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- Discard the Bool flag</span><span>
</span><span id="line-2257"></span><span>
</span><span id="line-2258"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#extendFvs"><span class="hs-identifier hs-type">extendFvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-2259"></span><span class="hs-comment">-- (extendFVs env s) returns</span><span>
</span><span id="line-2260"></span><span class="hs-comment">--     (s `union` env(s), env(s) `subset` s)</span><span>
</span><span id="line-2261"></span><span id="extendFvs"><span class="annot"><span class="annottext">extendFvs :: ImpRuleEdges -&gt; VarSet -&gt; (VarSet, Bool)
</span><a href="GHC.Core.Opt.OccurAnal.html#extendFvs"><span class="hs-identifier hs-var hs-var">extendFvs</span></a></span></span><span> </span><span id="local-6989586621680866488"><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866488"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680866487"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866487"><span class="hs-identifier hs-var">s</span></a></span></span><span>
</span><span id="line-2262"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges -&gt; Bool
forall key elt. UniqFM key elt -&gt; Bool
</span><a href="GHC.Types.Unique.FM.html#isNullUFM"><span class="hs-identifier hs-var">isNullUFM</span></a></span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866488"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-2263"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866487"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-2264"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2265"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866487"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866485"><span class="hs-identifier hs-var">extras</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866485"><span class="hs-identifier hs-var">extras</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#subVarSet"><span class="hs-operator hs-var">`subVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866487"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2266"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2267"></span><span>    </span><span class="annot"><a href="#local-6989586621680866485"><span class="hs-identifier hs-type">extras</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>    </span><span class="hs-comment">-- env(s)</span><span>
</span><span id="line-2268"></span><span>    </span><span id="local-6989586621680866485"><span class="annot"><span class="annottext">extras :: VarSet
</span><a href="#local-6989586621680866485"><span class="hs-identifier hs-var hs-var">extras</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; ImpRuleEdges -&gt; VarSet
forall elt a key. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqFM key elt -&gt; a
</span><a href="GHC.Types.Unique.FM.html#nonDetStrictFoldUFM"><span class="hs-identifier hs-var">nonDetStrictFoldUFM</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(ImpRuleEdges -&gt; VarSet) -&gt; ImpRuleEdges -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2269"></span><span>      </span><span class="hs-comment">-- It's OK to use nonDetStrictFoldUFM here because unionVarSet commutes</span><span>
</span><span id="line-2270"></span><span>             </span><span class="annot"><span class="annottext">(VarSet -&gt; CoreBndr -&gt; VarSet)
-&gt; ImpRuleEdges -&gt; VarEnv CoreBndr -&gt; ImpRuleEdges
forall elt1 elt2 elt3 key.
(elt1 -&gt; elt2 -&gt; elt3)
-&gt; UniqFM key elt1 -&gt; UniqFM key elt2 -&gt; UniqFM key elt3
</span><a href="GHC.Types.Unique.FM.html#intersectUFM_C"><span class="hs-identifier hs-var">intersectUFM_C</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680866481"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866481"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866481"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ImpRuleEdges
</span><a href="#local-6989586621680866488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; VarEnv CoreBndr
forall a. UniqSet a -&gt; UniqFM a a
</span><a href="GHC.Types.Unique.Set.html#getUniqSet"><span class="hs-identifier hs-var">getUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866487"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2271"></span><span>
</span><span id="line-2272"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                    Binder swap
*                                                                      *
************************************************************************

Note [Binder swap]
~~~~~~~~~~~~~~~~~~
The &quot;binder swap&quot; transformation swaps occurrence of the
scrutinee of a case for occurrences of the case-binder:

 (1)  case x of b { pi -&gt; ri }
         ==&gt;
      case x of b { pi -&gt; ri[b/x] }

 (2)  case (x |&gt; co) of b { pi -&gt; ri }
        ==&gt;
      case (x |&gt; co) of b { pi -&gt; ri[b |&gt; sym co/x] }

The substitution ri[b/x] etc is done by the occurrence analyser.
See Note [The binder-swap substitution].

There are two reasons for making this swap:

(A) It reduces the number of occurrences of the scrutinee, x.
    That in turn might reduce its occurrences to one, so we
    can inline it and save an allocation.  E.g.
      let x = factorial y in case x of b { I# v -&gt; ...x... }
    If we replace 'x' by 'b' in the alternative we get
      let x = factorial y in case x of b { I# v -&gt; ...b... }
    and now we can inline 'x', thus
      case (factorial y) of b { I# v -&gt; ...b... }

(B) The case-binder b has unfolding information; in the
    example above we know that b = I# v. That in turn allows
    nested cases to simplify.  Consider
       case x of b { I# v -&gt;
       ...(case x of b2 { I# v2 -&gt; rhs })...
    If we replace 'x' by 'b' in the alternative we get
       case x of b { I# v -&gt;
       ...(case b of b2 { I# v2 -&gt; rhs })...
    and now it is trivial to simplify the inner case:
       case x of b { I# v -&gt;
       ...(let b2 = b in rhs)...

    The same can happen even if the scrutinee is a variable
    with a cast: see Note [Case of cast]

The reason for doing these transformations /here in the occurrence
analyser/ is because it allows us to adjust the OccInfo for 'x' and
'b' as we go.

  * Suppose the only occurrences of 'x' are the scrutinee and in the
    ri; then this transformation makes it occur just once, and hence
    get inlined right away.

  * If instead the Simplifier replaces occurrences of x with
    occurrences of b, that will mess up b's occurrence info. That in
    turn might have consequences.

There is a danger though.  Consider
      let v = x +# y
      in case (f v) of w -&gt; ...v...v...
And suppose that (f v) expands to just v.  Then we'd like to
use 'w' instead of 'v' in the alternative.  But it may be too
late; we may have substituted the (cheap) x+#y for v in the
same simplifier pass that reduced (f v) to v.

I think this is just too bad.  CSE will recover some of it.

Note [The binder-swap substitution]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The binder-swap is implemented by the occ_bs_env field of OccEnv.
There are two main pieces:

* Given    case x |&gt; co of b { alts }
  we add [x :-&gt; (b, co)] to the occ_bs_env environment; this is
  done by addBndrSwap.

* Then, at an occurrence of a variable, we look up in the occ_bs_env
  to perform the swap. This is done by lookupBndrSwap.

Some tricky corners:

(BS1) We do the substitution before gathering occurrence info. So in
      the above example, an occurrence of x turns into an occurrence
      of b, and that's what we gather in the UsageDetails.  It's as
      if the binder-swap occurred before occurrence analysis. See
      the computation of fun_uds in occAnalApp.

(BS2) When doing a lookup in occ_bs_env, we may need to iterate,
      as you can see implemented in lookupBndrSwap.  Why?
      Consider   case x of a { 1# -&gt; e1; DEFAULT -&gt;
                 case x of b { 2# -&gt; e2; DEFAULT -&gt;
                 case x of c { 3# -&gt; e3; DEFAULT -&gt; ..x..a..b.. }}}
      At the first case addBndrSwap will extend occ_bs_env with
          [x :-&gt; a]
      At the second case we occ-anal the scrutinee 'x', which looks up
        'x in occ_bs_env, returning 'a', as it should.
      Then addBndrSwap will add [a :-&gt; b] to occ_bs_env, yielding
         occ_bs_env = [x :-&gt; a, a :-&gt; b]
      At the third case we'll again look up 'x' which returns 'a'.
      But we don't want to stop the lookup there, else we'll end up with
                 case x of a { 1# -&gt; e1; DEFAULT -&gt;
                 case a of b { 2# -&gt; e2; DEFAULT -&gt;
                 case a of c { 3# -&gt; e3; DEFAULT -&gt; ..a..b..c.. }}}
      Instead, we want iterate the lookup in addBndrSwap, to give
                 case x of a { 1# -&gt; e1; DEFAULT -&gt;
                 case a of b { 2# -&gt; e2; DEFAULT -&gt;
                 case b of c { 3# -&gt; e3; DEFAULT -&gt; ..c..c..c.. }}}
      This makes a particular difference for case-merge, which works
      only if the scrutinee is the case-binder of the immediately enclosing
      case (Note [Merge Nested Cases] in GHC.Core.Opt.Simplify.Utils
      See #19581 for the bug report that showed this up.

(BS3) We need care when shadowing.  Suppose [x :-&gt; b] is in occ_bs_env,
      and we encounter:
         - \x. blah
           Here we want to delete the x-binding from occ_bs_env

         - \b. blah
           This is harder: we really want to delete all bindings that
           have 'b' free in the range.  That is a bit tiresome to implement,
           so we compromise.  We keep occ_bs_rng, which is the set of
           free vars of rng(occc_bs_env).  If a binder shadows any of these
           variables, we discard all of occ_bs_env.  Safe, if a bit
           brutal.  NB, however: the simplifer de-shadows the code, so the
           next time around this won't happen.

      These checks are implemented in addInScope.

      The occurrence analyser itself does /not/ do cloning. It could, in
      principle, but it'd make it a bit more complicated and there is no
      great benefit. The simplifer uses cloning to get a no-shadowing
      situation, the care-when-shadowing behaviour above isn't needed for
      long.

(BS4) The domain of occ_bs_env can include GlobaIds.  Eg
         case M.foo of b { alts }
      We extend occ_bs_env with [M.foo :-&gt; b].  That's fine.

(BS5) We have to apply the occ_bs_env substitution uniformly,
      including to (local) rules and unfoldings.

Historical note
---------------
We used to do the binder-swap transformation by introducing
a proxy let-binding, thus;

   case x of b { pi -&gt; ri }
      ==&gt;
   case x of b { pi -&gt; let x = b in ri }

But that had two problems:

1. If 'x' is an imported GlobalId, we'd end up with a GlobalId
   on the LHS of a let-binding which isn't allowed.  We worked
   around this for a while by &quot;localising&quot; x, but it turned
   out to be very painful #16296,

2. In CorePrep we use the occurrence analyser to do dead-code
   elimination (see Note [Dead code in CorePrep]).  But that
   occasionally led to an unlifted let-binding
       case x of b { DEFAULT -&gt; let x::Int# = b in ... }
   which disobeys one of CorePrep's output invariants (no unlifted
   let-bindings) -- see #5433.

Doing a substitution (via occ_bs_env) is much better.

Note [Case of cast]
~~~~~~~~~~~~~~~~~~~
Consider        case (x `cast` co) of b { I# -&gt;
                ... (case (x `cast` co) of {...}) ...
We'd like to eliminate the inner case.  That is the motivation for
equation (2) in Note [Binder swap].  When we get to the inner case, we
inline x, cancel the casts, and away we go.

Note [Zap case binders in proxy bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From the original
     case x of cb(dead) { p -&gt; ...x... }
we will get
     case x of cb(live) { p -&gt; ...cb... }

Core Lint never expects to find an *occurrence* of an Id marked
as Dead, so we must zap the OccInfo on cb before making the
binding x = cb.  See #5028.

NB: the OccInfo on /occurrences/ really doesn't matter much; the simplifier
doesn't use it. So this is only to satisfy the perhaps-over-picky Lint.

Historical note [no-case-of-case]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We *used* to suppress the binder-swap in case expressions when
-fno-case-of-case is on.  Old remarks:
    &quot;This happens in the first simplifier pass,
    and enhances full laziness.  Here's the bad case:
            f = \ y -&gt; ...(case x of I# v -&gt; ...(case x of ...) ... )
    If we eliminate the inner case, we trap it inside the I# v -&gt; arm,
    which might prevent some full laziness happening.  I've seen this
    in action in spectral/cichelli/Prog.hs:
             [(m,n) | m &lt;- [1..max], n &lt;- [1..max]]
    Hence the check for NoCaseOfCase.&quot;
However, now the full-laziness pass itself reverses the binder-swap, so this
check is no longer necessary.

Historical note [Suppressing the case binder-swap]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This old note describes a problem that is also fixed by doing the
binder-swap in OccAnal:

    There is another situation when it might make sense to suppress the
    case-expression binde-swap. If we have

        case x of w1 { DEFAULT -&gt; case x of w2 { A -&gt; e1; B -&gt; e2 }
                       ...other cases .... }

    We'll perform the binder-swap for the outer case, giving

        case x of w1 { DEFAULT -&gt; case w1 of w2 { A -&gt; e1; B -&gt; e2 }
                       ...other cases .... }

    But there is no point in doing it for the inner case, because w1 can't
    be inlined anyway.  Furthermore, doing the case-swapping involves
    zapping w2's occurrence info (see paragraphs that follow), and that
    forces us to bind w2 when doing case merging.  So we get

        case x of w1 { A -&gt; let w2 = w1 in e1
                       B -&gt; let w2 = w1 in e2
                       ...other cases .... }

    This is plain silly in the common case where w2 is dead.

    Even so, I can't see a good way to implement this idea.  I tried
    not doing the binder-swap if the scrutinee was already evaluated
    but that failed big-time:

            data T = MkT !Int

            case v of w  { MkT x -&gt;
            case x of x1 { I# y1 -&gt;
            case x of x2 { I# y2 -&gt; ...

    Notice that because MkT is strict, x is marked &quot;evaluated&quot;.  But to
    eliminate the last case, we must either make sure that x (as well as
    x1) has unfolding MkT y1.  The straightforward thing to do is to do
    the binder-swap.  So this whole note is a no-op.

It's fixed by doing the binder-swap in OccAnal because we can do the
binder-swap unconditionally and still get occurrence analysis
information right.
-}</span><span>
</span><span id="line-2525"></span><span>
</span><span id="line-2526"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addBndrSwap"><span class="hs-identifier hs-type">addBndrSwap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span>
</span><span id="line-2527"></span><span class="hs-comment">-- See Note [The binder-swap substitution]</span><span>
</span><span id="line-2528"></span><span id="addBndrSwap"><span class="annot"><span class="annottext">addBndrSwap :: CoreExpr -&gt; CoreBndr -&gt; OccEnv -&gt; OccEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#addBndrSwap"><span class="hs-identifier hs-var hs-var">addBndrSwap</span></a></span></span><span> </span><span id="local-6989586621680866479"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866479"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680866478"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866478"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span>
</span><span id="line-2529"></span><span>            </span><span id="local-6989586621680866477"><span class="annot"><span class="annottext">env :: OccEnv
</span><a href="#local-6989586621680866477"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: OccEnv -&gt; VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866476"><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866476"><span class="hs-identifier hs-var">swap_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_rng :: OccEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var">occ_bs_rng</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866475"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866475"><span class="hs-identifier hs-var">rng_vars</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2530"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866474"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866474"><span class="hs-identifier hs-var">scrut_var</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866473"><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680866473"><span class="hs-identifier hs-var">mco</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Maybe (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866472"><span class="hs-identifier hs-var">get_scrut_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; CoreExpr -&gt; CoreExpr
forall b. (Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.Utils.html#stripTicksTopE"><span class="hs-identifier hs-var">stripTicksTopE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Tickish CoreBndr -&gt; Bool
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866479"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2531"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866474"><span class="hs-identifier hs-var">scrut_var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866478"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>
</span><span id="line-2532"></span><span>      </span><span class="hs-comment">-- Consider: case x of x { ... }</span><span>
</span><span id="line-2533"></span><span>      </span><span class="hs-comment">-- Do not add [x :-&gt; x] to occ_bs_env, else lookupBndrSwap will loop</span><span>
</span><span id="line-2534"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866477"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
-&gt; CoreBndr
-&gt; (CoreBndr, MCoercion)
-&gt; VarEnv (CoreBndr, MCoercion)
forall a. VarEnv a -&gt; CoreBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866476"><span class="hs-identifier hs-var">swap_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866474"><span class="hs-identifier hs-var">scrut_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866469"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680866473"><span class="hs-identifier hs-var">mco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2535"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_bs_rng :: VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_rng"><span class="hs-identifier hs-var">occ_bs_rng</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866475"><span class="hs-identifier hs-var">rng_vars</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; CoreBndr -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866469"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span>
</span><span id="line-2536"></span><span>                       </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercion -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfMCo"><span class="hs-identifier hs-var">tyCoVarsOfMCo</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680866473"><span class="hs-identifier hs-var">mco</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2537"></span><span>
</span><span id="line-2538"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2539"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866477"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-2540"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2541"></span><span>    </span><span class="annot"><a href="#local-6989586621680866472"><span class="hs-identifier hs-type">get_scrut_var</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCoercion"><span class="hs-identifier hs-type">MCoercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2542"></span><span>    </span><span id="local-6989586621680866472"><span class="annot"><span class="annottext">get_scrut_var :: CoreExpr -&gt; Maybe (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866472"><span class="hs-identifier hs-var hs-var">get_scrut_var</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680866466"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866466"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreBndr, MCoercion) -&gt; Maybe (CoreBndr, MCoercion)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866466"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2543"></span><span>    </span><span class="annot"><a href="#local-6989586621680866472"><span class="hs-identifier hs-var">get_scrut_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680866464"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866464"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866463"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866463"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreBndr, MCoercion) -&gt; Maybe (CoreBndr, MCoercion)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866464"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-var">MCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866463"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- See Note [Case of cast]</span><span>
</span><span id="line-2544"></span><span>    </span><span class="annot"><a href="#local-6989586621680866472"><span class="hs-identifier hs-var">get_scrut_var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (CoreBndr, MCoercion)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-2545"></span><span>
</span><span id="line-2546"></span><span>    </span><span id="local-6989586621680866469"><span class="annot"><span class="annottext">case_bndr' :: CoreBndr
</span><a href="#local-6989586621680866469"><span class="hs-identifier hs-var hs-var">case_bndr'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#zapIdOccInfo"><span class="hs-identifier hs-var">zapIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866478"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>
</span><span id="line-2547"></span><span>                 </span><span class="hs-comment">-- See Note [Zap case binders in proxy bindings]</span><span>
</span><span id="line-2548"></span><span>
</span><span id="line-2549"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#lookupBndrSwap"><span class="hs-identifier hs-type">lookupBndrSwap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2550"></span><span class="hs-comment">-- See Note [The binder-swap substitution]</span><span>
</span><span id="line-2551"></span><span class="hs-comment">-- Returns an expression of the same type as Id</span><span>
</span><span id="line-2552"></span><span id="lookupBndrSwap"><span class="annot"><span class="annottext">lookupBndrSwap :: OccEnv -&gt; CoreBndr -&gt; (CoreExpr, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupBndrSwap"><span class="hs-identifier hs-var hs-var">lookupBndrSwap</span></a></span></span><span> </span><span id="local-6989586621680866460"><span class="annot"><span class="annottext">env :: OccEnv
</span><a href="#local-6989586621680866460"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccEnv"><span class="hs-identifier hs-type">OccEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_bs_env :: OccEnv -&gt; VarEnv (CoreBndr, MCoercion)
</span><a href="GHC.Core.Opt.OccurAnal.html#occ_bs_env"><span class="hs-identifier hs-var">occ_bs_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866459"><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866459"><span class="hs-identifier hs-var">bs_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>  </span><span id="local-6989586621680866458"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866458"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2553"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
-&gt; CoreBndr -&gt; Maybe (CoreBndr, MCoercion)
forall a. VarEnv a -&gt; CoreBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv (CoreBndr, MCoercion)
</span><a href="#local-6989586621680866459"><span class="hs-identifier hs-var">bs_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866458"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-2554"></span><span>       </span><span class="annot"><span class="annottext">Maybe (CoreBndr, MCoercion)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreExpr
forall b. CoreBndr -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866458"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866458"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">;</span><span>
</span><span id="line-2555"></span><span>       </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866457"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866457"><span class="hs-identifier hs-var">bndr1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866456"><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680866456"><span class="hs-identifier hs-var">mco</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-2556"></span><span>
</span><span id="line-2557"></span><span>    </span><span class="hs-comment">-- Why do we iterate here?</span><span>
</span><span id="line-2558"></span><span>    </span><span class="hs-comment">-- See (BS2) in Note [The binder-swap substitution]</span><span>
</span><span id="line-2559"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccEnv -&gt; CoreBndr -&gt; (CoreExpr, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupBndrSwap"><span class="hs-identifier hs-var">lookupBndrSwap</span></a></span><span> </span><span class="annot"><span class="annottext">OccEnv
</span><a href="#local-6989586621680866460"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866457"><span class="hs-identifier hs-var">bndr1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2560"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680866455"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866455"><span class="hs-identifier hs-var">fun</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866454"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866454"><span class="hs-identifier hs-var">fun_id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; MCoercion -&gt; CoreExpr
forall {b}. Expr b -&gt; MCoercion -&gt; Expr b
</span><a href="#local-6989586621680866453"><span class="hs-identifier hs-var">add_cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866455"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680866456"><span class="hs-identifier hs-var">mco</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866454"><span class="hs-identifier hs-var">fun_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2561"></span><span>
</span><span id="line-2562"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2563"></span><span>    </span><span id="local-6989586621680866453"><span class="annot"><span class="annottext">add_cast :: Expr b -&gt; MCoercion -&gt; Expr b
</span><a href="#local-6989586621680866453"><span class="hs-identifier hs-var hs-var">add_cast</span></a></span></span><span> </span><span id="local-6989586621680866452"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866452"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866452"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-2564"></span><span>    </span><span class="annot"><a href="#local-6989586621680866453"><span class="hs-identifier hs-var">add_cast</span></a></span><span> </span><span id="local-6989586621680866451"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866451"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-type">MCo</span></a></span><span> </span><span id="local-6989586621680866450"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866450"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; CoercionR -&gt; Expr b
forall b. Expr b -&gt; CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680866451"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; CoercionR
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680866450"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2565"></span><span>    </span><span class="hs-comment">-- We must switch that 'co' to 'sym co';</span><span>
</span><span id="line-2566"></span><span>    </span><span class="hs-comment">-- see the comment with occ_bs_env</span><span>
</span><span id="line-2567"></span><span>    </span><span class="hs-comment">-- No need to test for isReflCo, because 'co' came from</span><span>
</span><span id="line-2568"></span><span>    </span><span class="hs-comment">-- a (Cast e co) and hence is unlikely to be Refl</span><span>
</span><span id="line-2569"></span><span>
</span><span id="line-2570"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection[OccurAnal-types]{OccEnv}
*                                                                      *
************************************************************************

Note [UsageDetails and zapping]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On many occasions, we must modify all gathered occurrence data at once. For
instance, all occurrences underneath a (non-one-shot) lambda set the
'occ_in_lam' flag to become 'True'. We could use 'mapVarEnv' to do this, but
that takes O(n) time and we will do this often---in particular, there are many
places where tail calls are not allowed, and each of these causes all variables
to get marked with 'NoTailCallInfo'.

Instead of relying on `mapVarEnv`, then, we carry three 'IdEnv's around along
with the 'OccInfoEnv'. Each of these extra environments is a &quot;zapped set&quot;
recording which variables have been zapped in some way. Zapping all occurrence
info then simply means setting the corresponding zapped set to the whole
'OccInfoEnv', a fast O(1) operation.
-}</span><span>
</span><span id="line-2592"></span><span>
</span><span id="line-2593"></span><span class="hs-keyword">type</span><span> </span><span id="OccInfoEnv"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccInfoEnv"><span class="hs-identifier hs-var">OccInfoEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-comment">-- A finite map from ids to their usage</span><span>
</span><span id="line-2594"></span><span>                </span><span class="hs-comment">-- INVARIANT: never IAmDead</span><span>
</span><span id="line-2595"></span><span>                </span><span class="hs-comment">-- (Deadness is signalled by not being in the map at all)</span><span>
</span><span id="line-2596"></span><span>
</span><span id="line-2597"></span><span class="hs-keyword">type</span><span> </span><span id="ZappedSet"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-var">ZappedSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccInfoEnv"><span class="hs-identifier hs-type">OccInfoEnv</span></a></span><span> </span><span class="hs-comment">-- Values are ignored</span><span>
</span><span id="line-2598"></span><span>
</span><span id="line-2599"></span><span class="hs-keyword">data</span><span> </span><span id="UsageDetails"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-var">UsageDetails</span></a></span></span><span>
</span><span id="line-2600"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="UD"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UD"><span class="hs-identifier hs-var">UD</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="ud_env"><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span></span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccInfoEnv"><span class="hs-identifier hs-type">OccInfoEnv</span></a></span><span>
</span><span id="line-2601"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ud_z_many"><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var hs-var">ud_z_many</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-type">ZappedSet</span></a></span><span>   </span><span class="hs-comment">-- apply 'markMany' to these</span><span>
</span><span id="line-2602"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ud_z_in_lam"><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var hs-var">ud_z_in_lam</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-type">ZappedSet</span></a></span><span>   </span><span class="hs-comment">-- apply 'markInsideLam' to these</span><span>
</span><span id="line-2603"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ud_z_no_tail"><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var hs-var">ud_z_no_tail</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-type">ZappedSet</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-comment">-- apply 'markNonTail' to these</span><span>
</span><span id="line-2604"></span><span>  </span><span class="hs-comment">-- INVARIANT: All three zapped sets are subsets of the OccInfoEnv</span><span>
</span><span id="line-2605"></span><span>
</span><span id="line-2606"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680866440"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2607"></span><span>  </span><span id="local-6989586621680866435"><span class="annot"><span class="annottext">ppr :: UsageDetails -&gt; SDoc
</span><a href="#local-6989586621680866435"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span id="local-6989586621680866434"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866434"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#flattenUsageDetails"><span class="hs-identifier hs-var">flattenUsageDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866434"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2608"></span><span>
</span><span id="line-2609"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-2610"></span><span class="hs-comment">-- UsageDetails API</span><span>
</span><span id="line-2611"></span><span>
</span><span id="line-2612"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-type">andUDs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#orUDs"><span class="hs-identifier hs-type">orUDs</span></a></span><span>
</span><span id="line-2613"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2614"></span><span id="andUDs"><span class="annot"><span class="annottext">andUDs :: UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-var hs-var">andUDs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OccInfo -&gt; OccInfo -&gt; OccInfo)
-&gt; UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#combineUsageDetailsWith"><span class="hs-identifier hs-var">combineUsageDetailsWith</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#addOccInfo"><span class="hs-identifier hs-var">addOccInfo</span></a></span><span>
</span><span id="line-2615"></span><span id="orUDs"><span class="annot"><span class="annottext">orUDs :: UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#orUDs"><span class="hs-identifier hs-var hs-var">orUDs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OccInfo -&gt; OccInfo -&gt; OccInfo)
-&gt; UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#combineUsageDetailsWith"><span class="hs-identifier hs-var">combineUsageDetailsWith</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#orOccInfo"><span class="hs-identifier hs-var">orOccInfo</span></a></span><span>
</span><span id="line-2616"></span><span>
</span><span id="line-2617"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#mkOneOcc"><span class="hs-identifier hs-type">mkOneOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#InterestingCxt"><span class="hs-identifier hs-type">InterestingCxt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2618"></span><span id="mkOneOcc"><span class="annot"><span class="annottext">mkOneOcc :: CoreBndr -&gt; InterestingCxt -&gt; JoinArity -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#mkOneOcc"><span class="hs-identifier hs-var hs-var">mkOneOcc</span></a></span></span><span> </span><span id="local-6989586621680866429"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866429"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680866428"><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866428"><span class="hs-identifier hs-var">int_cxt</span></a></span></span><span> </span><span id="local-6989586621680866427"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866427"><span class="hs-identifier hs-var">arity</span></a></span></span><span>
</span><span id="line-2619"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866429"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-2620"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo -&gt; OccInfoEnv
forall a. CoreBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#unitVarEnv"><span class="hs-identifier hs-var">unitVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866429"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866424"><span class="hs-identifier hs-var">occ_info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2621"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2622"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var">emptyDetails</span></a></span><span>
</span><span id="line-2623"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2624"></span><span>    </span><span id="local-6989586621680866424"><span class="annot"><span class="annottext">occ_info :: OccInfo
</span><a href="#local-6989586621680866424"><span class="hs-identifier hs-var hs-var">occ_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneOcc :: InsideLam -&gt; JoinArity -&gt; InterestingCxt -&gt; TailCallInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InsideLam
</span><a href="GHC.Types.Basic.html#NotInsideLam"><span class="hs-identifier hs-var">NotInsideLam</span></a></span><span>
</span><span id="line-2625"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_n_br :: JoinArity
</span><a href="GHC.Types.Basic.html#occ_n_br"><span class="hs-identifier hs-var">occ_n_br</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="GHC.Types.Basic.html#oneBranch"><span class="hs-identifier hs-var">oneBranch</span></a></span><span>
</span><span id="line-2626"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_int_cxt :: InterestingCxt
</span><a href="GHC.Types.Basic.html#occ_int_cxt"><span class="hs-identifier hs-var">occ_int_cxt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866428"><span class="hs-identifier hs-var">int_cxt</span></a></span><span>
</span><span id="line-2627"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-var">AlwaysTailCalled</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866427"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2628"></span><span>
</span><span id="line-2629"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addManyOccId"><span class="hs-identifier hs-type">addManyOccId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2630"></span><span class="hs-comment">-- Add the non-committal (id :-&gt; noOccInfo) to the usage details</span><span>
</span><span id="line-2631"></span><span id="addManyOccId"><span class="annot"><span class="annottext">addManyOccId :: UsageDetails -&gt; CoreBndr -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccId"><span class="hs-identifier hs-var hs-var">addManyOccId</span></a></span></span><span> </span><span id="local-6989586621680866419"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866419"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866418"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866418"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866419"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; CoreBndr -&gt; OccInfo -&gt; OccInfoEnv
forall a. VarEnv a -&gt; CoreBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866419"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866418"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#noOccInfo"><span class="hs-identifier hs-var">noOccInfo</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2632"></span><span>
</span><span id="line-2633"></span><span class="hs-comment">-- Add several occurrences, assumed not to be tail calls</span><span>
</span><span id="line-2634"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addManyOcc"><span class="hs-identifier hs-type">addManyOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2635"></span><span id="addManyOcc"><span class="annot"><span class="annottext">addManyOcc :: CoreBndr -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOcc"><span class="hs-identifier hs-var hs-var">addManyOcc</span></a></span></span><span> </span><span id="local-6989586621680866416"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866416"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680866415"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866415"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866416"><span class="hs-identifier hs-var">v</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccId"><span class="hs-identifier hs-var">addManyOccId</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866415"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866416"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-2636"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866415"><span class="hs-identifier hs-var">u</span></a></span><span>
</span><span id="line-2637"></span><span>        </span><span class="hs-comment">-- Give a non-committal binder info (i.e noOccInfo) because</span><span>
</span><span id="line-2638"></span><span>        </span><span class="hs-comment">--   a) Many copies of the specialised thing can appear</span><span>
</span><span id="line-2639"></span><span>        </span><span class="hs-comment">--   b) We don't want to substitute a BIG expression inside a RULE</span><span>
</span><span id="line-2640"></span><span>        </span><span class="hs-comment">--      even if that's the only occurrence of the thing</span><span>
</span><span id="line-2641"></span><span>        </span><span class="hs-comment">--      (Same goes for INLINE.)</span><span>
</span><span id="line-2642"></span><span>
</span><span id="line-2643"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-type">addManyOccs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2644"></span><span id="addManyOccs"><span class="annot"><span class="annottext">addManyOccs :: UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var hs-var">addManyOccs</span></a></span></span><span> </span><span id="local-6989586621680866414"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866414"><span class="hs-identifier hs-var">usage</span></a></span></span><span> </span><span id="local-6989586621680866413"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866413"><span class="hs-identifier hs-var">id_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; VarSet -&gt; UsageDetails
forall elt a. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqSet elt -&gt; a
</span><a href="GHC.Types.Unique.Set.html#nonDetStrictFoldUniqSet"><span class="hs-identifier hs-var">nonDetStrictFoldUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOcc"><span class="hs-identifier hs-var">addManyOcc</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866414"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866413"><span class="hs-identifier hs-var">id_set</span></a></span><span>
</span><span id="line-2645"></span><span>  </span><span class="hs-comment">-- It's OK to use nonDetStrictFoldUniqSet here because addManyOcc commutes</span><span>
</span><span id="line-2646"></span><span>
</span><span id="line-2647"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#delDetails"><span class="hs-identifier hs-type">delDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2648"></span><span id="delDetails"><span class="annot"><span class="annottext">delDetails :: UsageDetails -&gt; CoreBndr -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetails"><span class="hs-identifier hs-var hs-var">delDetails</span></a></span></span><span> </span><span id="local-6989586621680866410"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866410"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866409"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866409"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2649"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866410"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterUsageDetails"><span class="hs-operator hs-var">`alterUsageDetails`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccInfoEnv -&gt; CoreBndr -&gt; OccInfoEnv
forall a. VarEnv a -&gt; CoreBndr -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-operator hs-var">`delVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866409"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2650"></span><span>
</span><span id="line-2651"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-identifier hs-type">delDetailsList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2652"></span><span id="delDetailsList"><span class="annot"><span class="annottext">delDetailsList :: UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-identifier hs-var hs-var">delDetailsList</span></a></span></span><span> </span><span id="local-6989586621680866406"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866406"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866405"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866405"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-2653"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866406"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterUsageDetails"><span class="hs-operator hs-var">`alterUsageDetails`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccInfoEnv -&gt; [CoreBndr] -&gt; OccInfoEnv
forall a. VarEnv a -&gt; [CoreBndr] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866405"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2654"></span><span>
</span><span id="line-2655"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-type">emptyDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2656"></span><span id="emptyDetails"><span class="annot"><span class="annottext">emptyDetails :: UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#emptyDetails"><span class="hs-identifier hs-var hs-var">emptyDetails</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UD :: OccInfoEnv
-&gt; OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#UD"><span class="hs-identifier hs-type">UD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-2657"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_many :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var">ud_z_many</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-2658"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_in_lam :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-2659"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_no_tail :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var">ud_z_no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2660"></span><span>
</span><span id="line-2661"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#isEmptyDetails"><span class="hs-identifier hs-type">isEmptyDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2662"></span><span id="isEmptyDetails"><span class="annot"><span class="annottext">isEmptyDetails :: UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isEmptyDetails"><span class="hs-identifier hs-var hs-var">isEmptyDetails</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(OccInfoEnv -&gt; Bool)
-&gt; (UsageDetails -&gt; OccInfoEnv) -&gt; UsageDetails -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span>
</span><span id="line-2663"></span><span>
</span><span id="line-2664"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllMany"><span class="hs-identifier hs-type">markAllMany</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLam"><span class="hs-identifier hs-type">markAllInsideLam</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-type">markAllNonTail</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTail"><span class="hs-identifier hs-type">markAllManyNonTail</span></a></span><span>
</span><span id="line-2665"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2666"></span><span id="markAllMany"><span class="annot"><span class="annottext">markAllMany :: UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllMany"><span class="hs-identifier hs-var hs-var">markAllMany</span></a></span></span><span>          </span><span id="local-6989586621680866403"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866403"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866403"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_z_many :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var">ud_z_many</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866403"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2667"></span><span id="markAllInsideLam"><span class="annot"><span class="annottext">markAllInsideLam :: UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLam"><span class="hs-identifier hs-var hs-var">markAllInsideLam</span></a></span></span><span>     </span><span id="local-6989586621680866402"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866402"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866402"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_z_in_lam :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866402"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2668"></span><span id="markAllNonTail"><span class="annot"><span class="annottext">markAllNonTail :: UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var hs-var">markAllNonTail</span></a></span></span><span> </span><span id="local-6989586621680866401"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866401"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866401"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_z_no_tail :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var">ud_z_no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866401"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2669"></span><span>
</span><span id="line-2670"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-type">markAllInsideLamIf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTailIf"><span class="hs-identifier hs-type">markAllNonTailIf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2671"></span><span>
</span><span id="line-2672"></span><span id="markAllInsideLamIf"><span class="annot"><span class="annottext">markAllInsideLamIf :: Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-var hs-var">markAllInsideLamIf</span></a></span></span><span>  </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span id="local-6989586621680866400"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866400"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLam"><span class="hs-identifier hs-var">markAllInsideLam</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866400"><span class="hs-identifier hs-var">ud</span></a></span><span>
</span><span id="line-2673"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-var">markAllInsideLamIf</span></a></span><span>  </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span id="local-6989586621680866399"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866399"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866399"><span class="hs-identifier hs-var">ud</span></a></span><span>
</span><span id="line-2674"></span><span>
</span><span id="line-2675"></span><span id="markAllNonTailIf"><span class="annot"><span class="annottext">markAllNonTailIf :: Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTailIf"><span class="hs-identifier hs-var hs-var">markAllNonTailIf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span id="local-6989586621680866398"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866398"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866398"><span class="hs-identifier hs-var">ud</span></a></span><span>
</span><span id="line-2676"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTailIf"><span class="hs-identifier hs-var">markAllNonTailIf</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span id="local-6989586621680866397"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866397"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866397"><span class="hs-identifier hs-var">ud</span></a></span><span>
</span><span id="line-2677"></span><span>
</span><span id="line-2678"></span><span>
</span><span id="line-2679"></span><span id="markAllManyNonTail"><span class="annot"><span class="annottext">markAllManyNonTail :: UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTail"><span class="hs-identifier hs-var hs-var">markAllManyNonTail</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllMany"><span class="hs-identifier hs-var">markAllMany</span></a></span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails)
-&gt; (UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTail"><span class="hs-identifier hs-var">markAllNonTail</span></a></span><span> </span><span class="hs-comment">-- effectively sets to noOccInfo</span><span>
</span><span id="line-2680"></span><span>
</span><span id="line-2681"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTailIf"><span class="hs-identifier hs-type">markAllManyNonTailIf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>              </span><span class="hs-comment">-- If this is true</span><span>
</span><span id="line-2682"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>      </span><span class="hs-comment">-- Then do markAllManyNonTail on this</span><span>
</span><span id="line-2683"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2684"></span><span id="markAllManyNonTailIf"><span class="annot"><span class="annottext">markAllManyNonTailIf :: Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTailIf"><span class="hs-identifier hs-var hs-var">markAllManyNonTailIf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span id="local-6989586621680866396"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866396"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTail"><span class="hs-identifier hs-var">markAllManyNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866396"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-2685"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markAllManyNonTailIf"><span class="hs-identifier hs-var">markAllManyNonTailIf</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span id="local-6989586621680866395"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866395"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866395"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-2686"></span><span>
</span><span id="line-2687"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-type">lookupDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span>
</span><span id="line-2688"></span><span id="lookupDetails"><span class="annot"><span class="annottext">lookupDetails :: UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var hs-var">lookupDetails</span></a></span></span><span> </span><span id="local-6989586621680866393"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866393"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866392"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866392"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-2689"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866392"><span class="hs-identifier hs-var">id</span></a></span><span>  </span><span class="hs-comment">-- We do not currently gather occurrence info (from types)</span><span>
</span><span id="line-2690"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#noOccInfo"><span class="hs-identifier hs-var">noOccInfo</span></a></span><span>   </span><span class="hs-comment">-- for CoVars, so we must conservatively mark them as used</span><span>
</span><span id="line-2691"></span><span>                </span><span class="hs-comment">-- See Note [DoO not mark CoVars as dead]</span><span>
</span><span id="line-2692"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2693"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; CoreBndr -&gt; Maybe OccInfo
forall a. VarEnv a -&gt; CoreBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866393"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866392"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2694"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680866390"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866390"><span class="hs-identifier hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#doZapping"><span class="hs-identifier hs-var">doZapping</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866393"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866392"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866390"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2695"></span><span>      </span><span class="annot"><span class="annottext">Maybe OccInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#IAmDead"><span class="hs-identifier hs-var">IAmDead</span></a></span><span>
</span><span id="line-2696"></span><span>
</span><span id="line-2697"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#usedIn"><span class="hs-identifier hs-type">usedIn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2698"></span><span id="local-6989586621680866387"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866387"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="usedIn"><span class="annot"><span class="annottext">usedIn :: CoreBndr -&gt; UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#usedIn"><span class="hs-operator hs-var hs-var">`usedIn`</span></a></span></span><span> </span><span id="local-6989586621680866386"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866386"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866387"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866387"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfoEnv -&gt; Bool
forall a. CoreBndr -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866386"><span class="hs-identifier hs-var">ud</span></a></span><span>
</span><span id="line-2699"></span><span>
</span><span id="line-2700"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-type">udFreeVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2701"></span><span class="hs-comment">-- Find the subset of bndrs that are mentioned in uds</span><span>
</span><span id="line-2702"></span><span id="udFreeVars"><span class="annot"><span class="annottext">udFreeVars :: VarSet -&gt; UsageDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.OccurAnal.html#udFreeVars"><span class="hs-identifier hs-var hs-var">udFreeVars</span></a></span></span><span> </span><span id="local-6989586621680866382"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866382"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621680866381"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866381"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; OccInfoEnv -&gt; VarSet
forall key b. UniqSet key -&gt; UniqFM key b -&gt; UniqSet key
</span><a href="GHC.Types.Unique.Set.html#restrictUniqSetToUFM"><span class="hs-identifier hs-var">restrictUniqSetToUFM</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680866382"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866381"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2703"></span><span>
</span><span id="line-2704"></span><span class="hs-comment">{- Note [Do not mark CoVars as dead]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's obviously wrong to mark CoVars as dead if they are used.
Currently we don't traverse types to gather usase info for CoVars,
so we had better treat them as having noOccInfo.

This showed up in #15696 we had something like
  case eq_sel d of co -&gt; ...(typeError @(...co...) &quot;urk&quot;)...

Then 'd' was substituted by a dictionary, so the expression
simpified to
  case (Coercion &lt;blah&gt;) of co -&gt; ...(typeError @(...co...) &quot;urk&quot;)...

But then the &quot;drop the case altogether&quot; equation of rebuildCase
thought that 'co' was dead, and discarded the entire case. Urk!

I have no idea how we managed to avoid this pitfall for so long!
-}</span><span>
</span><span id="line-2722"></span><span>
</span><span id="line-2723"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-2724"></span><span class="hs-comment">-- Auxiliary functions for UsageDetails implementation</span><span>
</span><span id="line-2725"></span><span>
</span><span id="line-2726"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#combineUsageDetailsWith"><span class="hs-identifier hs-type">combineUsageDetailsWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2727"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2728"></span><span id="combineUsageDetailsWith"><span class="annot"><span class="annottext">combineUsageDetailsWith :: (OccInfo -&gt; OccInfo -&gt; OccInfo)
-&gt; UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#combineUsageDetailsWith"><span class="hs-identifier hs-var hs-var">combineUsageDetailsWith</span></a></span></span><span> </span><span id="local-6989586621680866379"><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="#local-6989586621680866379"><span class="hs-identifier hs-var">plus_occ_info</span></a></span></span><span> </span><span id="local-6989586621680866378"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span></span><span> </span><span id="local-6989586621680866377"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span></span><span>
</span><span id="line-2729"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isEmptyDetails"><span class="hs-identifier hs-var">isEmptyDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span>
</span><span id="line-2730"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#isEmptyDetails"><span class="hs-identifier hs-var">isEmptyDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span>
</span><span id="line-2731"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2732"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UD :: OccInfoEnv
-&gt; OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#UD"><span class="hs-identifier hs-type">UD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OccInfo -&gt; OccInfo -&gt; OccInfo)
-&gt; OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv
forall a. (a -&gt; a -&gt; a) -&gt; VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv_C"><span class="hs-identifier hs-var">plusVarEnv_C</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="#local-6989586621680866379"><span class="hs-identifier hs-var">plus_occ_info</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2733"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_many :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var">ud_z_many</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-identifier hs-var">plusVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var hs-var">ud_z_many</span></a></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var hs-var">ud_z_many</span></a></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2734"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_in_lam :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-identifier hs-var">plusVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2735"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_no_tail :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var">ud_z_no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-identifier hs-var">plusVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var hs-var">ud_z_no_tail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866378"><span class="hs-identifier hs-var">ud1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var hs-var">ud_z_no_tail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866377"><span class="hs-identifier hs-var">ud2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2736"></span><span>
</span><span id="line-2737"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#doZapping"><span class="hs-identifier hs-type">doZapping</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span>
</span><span id="line-2738"></span><span id="doZapping"><span class="annot"><span class="annottext">doZapping :: UsageDetails -&gt; CoreBndr -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#doZapping"><span class="hs-identifier hs-var hs-var">doZapping</span></a></span></span><span> </span><span id="local-6989586621680866375"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866375"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866374"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866374"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680866373"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866373"><span class="hs-identifier hs-var">occ</span></a></span></span><span>
</span><span id="line-2739"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Unique -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#doZappingByUnique"><span class="hs-identifier hs-var">doZappingByUnique</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866375"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unique
</span><a href="GHC.Types.Var.html#varUnique"><span class="hs-identifier hs-var">varUnique</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866374"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866373"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2740"></span><span>
</span><span id="line-2741"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#doZappingByUnique"><span class="hs-identifier hs-type">doZappingByUnique</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span>
</span><span id="line-2742"></span><span id="doZappingByUnique"><span class="annot"><span class="annottext">doZappingByUnique :: UsageDetails -&gt; Unique -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#doZappingByUnique"><span class="hs-identifier hs-var hs-var">doZappingByUnique</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UD"><span class="hs-identifier hs-type">UD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_z_many :: UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var">ud_z_many</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866371"><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866371"><span class="hs-identifier hs-var">many</span></a></span></span><span>
</span><span id="line-2743"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_in_lam :: UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var">ud_z_in_lam</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866370"><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866370"><span class="hs-identifier hs-var">in_lam</span></a></span></span><span>
</span><span id="line-2744"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_no_tail :: UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var">ud_z_no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866369"><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866369"><span class="hs-identifier hs-var">no_tail</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2745"></span><span>                  </span><span id="local-6989586621680866368"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680866368"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span id="local-6989586621680866367"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866367"><span class="hs-identifier hs-var">occ</span></a></span></span><span>
</span><span id="line-2746"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866366"><span class="hs-identifier hs-var">occ2</span></a></span><span>
</span><span id="line-2747"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2748"></span><span>    </span><span id="local-6989586621680866365"><span class="annot"><span class="annottext">occ1 :: OccInfo
</span><a href="#local-6989586621680866365"><span class="hs-identifier hs-var hs-var">occ1</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680866368"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccInfoEnv -&gt; Bool
forall a. Unique -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnvByKey"><span class="hs-operator hs-var">`elemVarEnvByKey`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866371"><span class="hs-identifier hs-var">many</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markMany"><span class="hs-identifier hs-var">markMany</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866367"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2749"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680866368"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccInfoEnv -&gt; Bool
forall a. Unique -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnvByKey"><span class="hs-operator hs-var">`elemVarEnvByKey`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866370"><span class="hs-identifier hs-var">in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markInsideLam"><span class="hs-identifier hs-var">markInsideLam</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866367"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2750"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866367"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2751"></span><span>    </span><span id="local-6989586621680866366"><span class="annot"><span class="annottext">occ2 :: OccInfo
</span><a href="#local-6989586621680866366"><span class="hs-identifier hs-var hs-var">occ2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680866368"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccInfoEnv -&gt; Bool
forall a. Unique -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnvByKey"><span class="hs-operator hs-var">`elemVarEnvByKey`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
</span><a href="#local-6989586621680866369"><span class="hs-identifier hs-var">no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-var">markNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866365"><span class="hs-identifier hs-var">occ1</span></a></span><span>
</span><span id="line-2752"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866365"><span class="hs-identifier hs-var">occ1</span></a></span><span>
</span><span id="line-2753"></span><span>
</span><span id="line-2754"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#alterZappedSets"><span class="hs-identifier hs-type">alterZappedSets</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-type">ZappedSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#ZappedSet"><span class="hs-identifier hs-type">ZappedSet</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2755"></span><span id="alterZappedSets"><span class="annot"><span class="annottext">alterZappedSets :: UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterZappedSets"><span class="hs-identifier hs-var hs-var">alterZappedSets</span></a></span></span><span> </span><span id="local-6989586621680866359"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866359"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866358"><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866358"><span class="hs-identifier hs-var">f</span></a></span></span><span>
</span><span id="line-2756"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866359"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_z_many :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var">ud_z_many</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866358"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_many"><span class="hs-identifier hs-var hs-var">ud_z_many</span></a></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866359"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2757"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_in_lam :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866358"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_in_lam"><span class="hs-identifier hs-var hs-var">ud_z_in_lam</span></a></span><span>  </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866359"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2758"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_z_no_tail :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var">ud_z_no_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866358"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_z_no_tail"><span class="hs-identifier hs-var hs-var">ud_z_no_tail</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866359"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2759"></span><span>
</span><span id="line-2760"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#alterUsageDetails"><span class="hs-identifier hs-type">alterUsageDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccInfoEnv"><span class="hs-identifier hs-type">OccInfoEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#OccInfoEnv"><span class="hs-identifier hs-type">OccInfoEnv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2761"></span><span id="alterUsageDetails"><span class="annot"><span class="annottext">alterUsageDetails :: UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterUsageDetails"><span class="hs-identifier hs-var hs-var">alterUsageDetails</span></a></span></span><span> </span><span id="local-6989586621680866357"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866357"><span class="hs-identifier hs-var">ud</span></a></span></span><span> </span><span id="local-6989586621680866356"><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866356"><span class="hs-identifier hs-var">f</span></a></span></span><span>
</span><span id="line-2762"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866357"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866356"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866357"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterZappedSets"><span class="hs-operator hs-var">`alterZappedSets`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv
</span><a href="#local-6989586621680866356"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-2763"></span><span>
</span><span id="line-2764"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#flattenUsageDetails"><span class="hs-identifier hs-type">flattenUsageDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2765"></span><span id="flattenUsageDetails"><span class="annot"><span class="annottext">flattenUsageDetails :: UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#flattenUsageDetails"><span class="hs-identifier hs-var hs-var">flattenUsageDetails</span></a></span></span><span> </span><span id="local-6989586621680866355"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866355"><span class="hs-identifier hs-var">ud</span></a></span></span><span>
</span><span id="line-2766"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866355"><span class="hs-identifier hs-var">ud</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_env :: OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var">ud_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Unique -&gt; OccInfo -&gt; OccInfo) -&gt; OccInfoEnv -&gt; OccInfoEnv
forall elt1 elt2 key.
(Unique -&gt; elt1 -&gt; elt2) -&gt; UniqFM key elt1 -&gt; UniqFM key elt2
</span><a href="GHC.Types.Unique.FM.html#mapUFM_Directly"><span class="hs-identifier hs-var">mapUFM_Directly</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; Unique -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#doZappingByUnique"><span class="hs-identifier hs-var">doZappingByUnique</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866355"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; OccInfoEnv
</span><a href="GHC.Core.Opt.OccurAnal.html#ud_env"><span class="hs-identifier hs-var hs-var">ud_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866355"><span class="hs-identifier hs-var">ud</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2767"></span><span>      </span><span class="annot"><span class="annottext">UsageDetails -&gt; (OccInfoEnv -&gt; OccInfoEnv) -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#alterZappedSets"><span class="hs-operator hs-var">`alterZappedSets`</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv -&gt; OccInfoEnv -&gt; OccInfoEnv
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfoEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-2768"></span><span>
</span><span id="line-2769"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-2770"></span><span class="hs-comment">-- See Note [Adjusting right-hand sides]</span><span>
</span><span id="line-2771"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#adjustRhsUsage"><span class="hs-identifier hs-type">adjustRhsUsage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span>
</span><span id="line-2772"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Outer lambdas, AFTER occ anal</span><span>
</span><span id="line-2773"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>   </span><span class="hs-comment">-- From body of lambda</span><span>
</span><span id="line-2774"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2775"></span><span id="adjustRhsUsage"><span class="annot"><span class="annottext">adjustRhsUsage :: Maybe JoinArity
-&gt; RecFlag -&gt; [CoreBndr] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#adjustRhsUsage"><span class="hs-identifier hs-var hs-var">adjustRhsUsage</span></a></span></span><span> </span><span id="local-6989586621680866353"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866353"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680866352"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680866352"><span class="hs-identifier hs-var">rec_flag</span></a></span></span><span> </span><span id="local-6989586621680866351"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866351"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621680866350"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866350"><span class="hs-identifier hs-var">usage</span></a></span></span><span>
</span><span id="line-2776"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllInsideLamIf"><span class="hs-identifier hs-var">markAllInsideLamIf</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866349"><span class="hs-identifier hs-var">one_shot</span></a></span><span class="hs-special">)</span><span>   </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2777"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#markAllNonTailIf"><span class="hs-identifier hs-var">markAllNonTailIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866348"><span class="hs-identifier hs-var">exact_join</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails) -&gt; UsageDetails -&gt; UsageDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2778"></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866350"><span class="hs-identifier hs-var">usage</span></a></span><span>
</span><span id="line-2779"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2780"></span><span>    </span><span id="local-6989586621680866349"><span class="annot"><span class="annottext">one_shot :: Bool
</span><a href="#local-6989586621680866349"><span class="hs-identifier hs-var hs-var">one_shot</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866353"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2781"></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680866345"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866345"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span>
</span><span id="line-2782"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isRec"><span class="hs-identifier hs-var">isRec</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680866352"><span class="hs-identifier hs-var">rec_flag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2783"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isOneShotBndr"><span class="hs-identifier hs-var">isOneShotBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. JoinArity -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#drop"><span class="hs-identifier hs-var">drop</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866345"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866351"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2784"></span><span>                 </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isOneShotBndr"><span class="hs-identifier hs-var">isOneShotBndr</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866351"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2785"></span><span>
</span><span id="line-2786"></span><span>    </span><span id="local-6989586621680866348"><span class="annot"><span class="annottext">exact_join :: Bool
</span><a href="#local-6989586621680866348"><span class="hs-identifier hs-var hs-var">exact_join</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity -&gt; [CoreBndr] -&gt; Bool
forall a. Maybe JoinArity -&gt; [a] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#exactJoin"><span class="hs-identifier hs-var">exactJoin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866353"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866351"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2787"></span><span>
</span><span id="line-2788"></span><span id="local-6989586621680867418"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#exactJoin"><span class="hs-identifier hs-type">exactJoin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680867418"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-2789"></span><span id="exactJoin"><span class="annot"><span class="annottext">exactJoin :: forall a. Maybe JoinArity -&gt; [a] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#exactJoin"><span class="hs-identifier hs-var hs-var">exactJoin</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>           </span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2790"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#exactJoin"><span class="hs-identifier hs-var">exactJoin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680866342"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866342"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680866341"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680866341"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680866341"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; JoinArity -&gt; Bool
forall a. [a] -&gt; JoinArity -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthIs"><span class="hs-operator hs-var">`lengthIs`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866342"><span class="hs-identifier hs-var">join_arity</span></a></span><span>
</span><span id="line-2791"></span><span>  </span><span class="hs-comment">-- Remember join_arity includes type binders</span><span>
</span><span id="line-2792"></span><span>
</span><span id="line-2793"></span><span class="hs-keyword">type</span><span> </span><span id="IdWithOccInfo"><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-var">IdWithOccInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-2794"></span><span>
</span><span id="line-2795"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinders"><span class="hs-identifier hs-type">tagLamBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>          </span><span class="hs-comment">-- Of scope</span><span>
</span><span id="line-2796"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>                  </span><span class="hs-comment">-- Binders</span><span>
</span><span id="line-2797"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>        </span><span class="hs-comment">-- Details with binders removed</span><span>
</span><span id="line-2798"></span><span>                 </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-type">IdWithOccInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- Tagged binders</span><span>
</span><span id="line-2799"></span><span id="tagLamBinders"><span class="annot"><span class="annottext">tagLamBinders :: UsageDetails -&gt; [CoreBndr] -&gt; (UsageDetails, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinders"><span class="hs-identifier hs-var hs-var">tagLamBinders</span></a></span></span><span> </span><span id="local-6989586621680866339"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866339"><span class="hs-identifier hs-var">usage</span></a></span></span><span> </span><span id="local-6989586621680866338"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866338"><span class="hs-identifier hs-var">binders</span></a></span></span><span>
</span><span id="line-2800"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866337"><span class="hs-identifier hs-var">usage'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
-&gt; (UsageDetails, [CoreBndr]) -&gt; (UsageDetails, [CoreBndr])
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866337"><span class="hs-identifier hs-var">usage'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866336"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2801"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2802"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680866337"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866337"><span class="hs-identifier hs-var">usage'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866336"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866336"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr))
-&gt; UsageDetails -&gt; [CoreBndr] -&gt; (UsageDetails, [CoreBndr])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumR"><span class="hs-identifier hs-var">mapAccumR</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinder"><span class="hs-identifier hs-var">tagLamBinder</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866339"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866338"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-2803"></span><span>
</span><span id="line-2804"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinder"><span class="hs-identifier hs-type">tagLamBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>       </span><span class="hs-comment">-- Of scope</span><span>
</span><span id="line-2805"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>                 </span><span class="hs-comment">-- Binder</span><span>
</span><span id="line-2806"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>     </span><span class="hs-comment">-- Details with binder removed</span><span>
</span><span id="line-2807"></span><span>                 </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-type">IdWithOccInfo</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- Tagged binders</span><span>
</span><span id="line-2808"></span><span class="hs-comment">-- Used for lambda and case binders</span><span>
</span><span id="line-2809"></span><span class="hs-comment">-- It copes with the fact that lambda bindings can have a</span><span>
</span><span id="line-2810"></span><span class="hs-comment">-- stable unfolding, used for join points</span><span>
</span><span id="line-2811"></span><span id="tagLamBinder"><span class="annot"><span class="annottext">tagLamBinder :: UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagLamBinder"><span class="hs-identifier hs-var hs-var">tagLamBinder</span></a></span></span><span> </span><span id="local-6989586621680866333"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866333"><span class="hs-identifier hs-var">usage</span></a></span></span><span> </span><span id="local-6989586621680866332"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2812"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866331"><span class="hs-identifier hs-var">usage2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866330"><span class="hs-identifier hs-var">bndr'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2813"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2814"></span><span>        </span><span id="local-6989586621680866329"><span class="annot"><span class="annottext">occ :: OccInfo
</span><a href="#local-6989586621680866329"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var">lookupDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866333"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2815"></span><span>        </span><span id="local-6989586621680866330"><span class="annot"><span class="annottext">bndr' :: CoreBndr
</span><a href="#local-6989586621680866330"><span class="hs-identifier hs-var hs-var">bndr'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#setBinderOcc"><span class="hs-identifier hs-var">setBinderOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-var">markNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866329"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2816"></span><span>                   </span><span class="hs-comment">-- Don't try to make an argument into a join point</span><span>
</span><span id="line-2817"></span><span>        </span><span id="local-6989586621680866327"><span class="annot"><span class="annottext">usage1 :: UsageDetails
</span><a href="#local-6989586621680866327"><span class="hs-identifier hs-var hs-var">usage1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866333"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetails"><span class="hs-operator hs-var">`delDetails`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2818"></span><span>        </span><span id="local-6989586621680866331"><span class="annot"><span class="annottext">usage2 :: UsageDetails
</span><a href="#local-6989586621680866331"><span class="hs-identifier hs-var hs-var">usage2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; VarSet -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#addManyOccs"><span class="hs-identifier hs-var">addManyOccs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866327"><span class="hs-identifier hs-var">usage1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#idUnfoldingVars"><span class="hs-identifier hs-var">idUnfoldingVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866332"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2819"></span><span>                               </span><span class="hs-comment">-- This is effectively the RHS of a</span><span>
</span><span id="line-2820"></span><span>                               </span><span class="hs-comment">-- non-join-point binding, so it's okay to use</span><span>
</span><span id="line-2821"></span><span>                               </span><span class="hs-comment">-- addManyOccsSet, which assumes no tail calls</span><span>
</span><span id="line-2822"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866327"><span class="hs-identifier hs-var">usage1</span></a></span><span>
</span><span id="line-2823"></span><span>
</span><span id="line-2824"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#tagNonRecBinder"><span class="hs-identifier hs-type">tagNonRecBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>           </span><span class="hs-comment">-- At top level?</span><span>
</span><span id="line-2825"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>           </span><span class="hs-comment">-- Of scope</span><span>
</span><span id="line-2826"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span>               </span><span class="hs-comment">-- Binder</span><span>
</span><span id="line-2827"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- Details with binder removed</span><span>
</span><span id="line-2828"></span><span>                    </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-type">IdWithOccInfo</span></a></span><span class="hs-special">)</span><span>        </span><span class="hs-comment">-- Tagged binder</span><span>
</span><span id="line-2829"></span><span>
</span><span id="line-2830"></span><span id="tagNonRecBinder"><span class="annot"><span class="annottext">tagNonRecBinder :: TopLevelFlag
-&gt; UsageDetails -&gt; CoreBndr -&gt; (UsageDetails, CoreBndr)
</span><a href="GHC.Core.Opt.OccurAnal.html#tagNonRecBinder"><span class="hs-identifier hs-var hs-var">tagNonRecBinder</span></a></span></span><span> </span><span id="local-6989586621680866325"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866325"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680866324"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866324"><span class="hs-identifier hs-var">usage</span></a></span></span><span> </span><span id="local-6989586621680866323"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866323"><span class="hs-identifier hs-var">binder</span></a></span></span><span>
</span><span id="line-2831"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-2832"></span><span>     </span><span id="local-6989586621680866322"><span class="annot"><span class="annottext">occ :: OccInfo
</span><a href="#local-6989586621680866322"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var">lookupDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866324"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866323"><span class="hs-identifier hs-var">binder</span></a></span><span>
</span><span id="line-2833"></span><span>     </span><span id="local-6989586621680866321"><span class="annot"><span class="annottext">will_be_join :: Bool
</span><a href="#local-6989586621680866321"><span class="hs-identifier hs-var hs-var">will_be_join</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; UsageDetails -&gt; [CoreBndr] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#decideJoinPointHood"><span class="hs-identifier hs-var">decideJoinPointHood</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866325"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866324"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866323"><span class="hs-identifier hs-var">binder</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2834"></span><span>     </span><span id="local-6989586621680866319"><span class="annot"><span class="annottext">occ' :: OccInfo
</span><a href="#local-6989586621680866319"><span class="hs-identifier hs-var hs-var">occ'</span></a></span></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866321"><span class="hs-identifier hs-var">will_be_join</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- must already be marked AlwaysTailCalled</span><span>
</span><span id="line-2835"></span><span>                              </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">isAlwaysTailCalled</span><span> </span><span class="hs-identifier">occ</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">occ</span><span>
</span><span id="line-2836"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-var">markNonTail</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866322"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2837"></span><span>     </span><span id="local-6989586621680866315"><span class="annot"><span class="annottext">binder' :: CoreBndr
</span><a href="#local-6989586621680866315"><span class="hs-identifier hs-var hs-var">binder'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#setBinderOcc"><span class="hs-identifier hs-var">setBinderOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866319"><span class="hs-identifier hs-var">occ'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866323"><span class="hs-identifier hs-var">binder</span></a></span><span>
</span><span id="line-2838"></span><span>     </span><span id="local-6989586621680866314"><span class="annot"><span class="annottext">usage' :: UsageDetails
</span><a href="#local-6989586621680866314"><span class="hs-identifier hs-var hs-var">usage'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866324"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetails"><span class="hs-operator hs-var">`delDetails`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866323"><span class="hs-identifier hs-var">binder</span></a></span><span>
</span><span id="line-2839"></span><span>   </span><span class="hs-keyword">in</span><span>
</span><span id="line-2840"></span><span>   </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866314"><span class="hs-identifier hs-var">usage'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
-&gt; (UsageDetails, CoreBndr) -&gt; (UsageDetails, CoreBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866314"><span class="hs-identifier hs-var">usage'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866315"><span class="hs-identifier hs-var">binder'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2841"></span><span>
</span><span id="line-2842"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#tagRecBinders"><span class="hs-identifier hs-type">tagRecBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>           </span><span class="hs-comment">-- At top level?</span><span>
</span><span id="line-2843"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>           </span><span class="hs-comment">-- Of body of let ONLY</span><span>
</span><span id="line-2844"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">,</span><span>            </span><span class="hs-comment">-- Binder</span><span>
</span><span id="line-2845"></span><span>                   </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>        </span><span class="hs-comment">-- RHS usage details</span><span>
</span><span id="line-2846"></span><span>                   </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- Lambdas in new RHS</span><span>
</span><span id="line-2847"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- Adjusted details for whole scope,</span><span>
</span><span id="line-2848"></span><span>                                        </span><span class="hs-comment">-- with binders removed</span><span>
</span><span id="line-2849"></span><span>                  </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#IdWithOccInfo"><span class="hs-identifier hs-type">IdWithOccInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- Tagged binders</span><span>
</span><span id="line-2850"></span><span class="hs-comment">-- Substantially more complicated than non-recursive case. Need to adjust RHS</span><span>
</span><span id="line-2851"></span><span class="hs-comment">-- details *before* tagging binders (because the tags depend on the RHSes).</span><span>
</span><span id="line-2852"></span><span id="tagRecBinders"><span class="annot"><span class="annottext">tagRecBinders :: TopLevelFlag
-&gt; UsageDetails
-&gt; [(CoreBndr, UsageDetails, [CoreBndr])]
-&gt; (UsageDetails, [CoreBndr])
</span><a href="GHC.Core.Opt.OccurAnal.html#tagRecBinders"><span class="hs-identifier hs-var hs-var">tagRecBinders</span></a></span></span><span> </span><span id="local-6989586621680866313"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866313"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680866312"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866312"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span> </span><span id="local-6989586621680866311"><span class="annot"><span class="annottext">[(CoreBndr, UsageDetails, [CoreBndr])]
</span><a href="#local-6989586621680866311"><span class="hs-identifier hs-var">triples</span></a></span></span><span>
</span><span id="line-2853"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-2854"></span><span>     </span><span class="hs-special">(</span><span id="local-6989586621680866310"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866310"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866309"><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866309"><span class="hs-identifier hs-var">rhs_udss</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[[CoreBndr]]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, UsageDetails, [CoreBndr])]
-&gt; ([CoreBndr], [UsageDetails], [[CoreBndr]])
forall a b c. [(a, b, c)] -&gt; ([a], [b], [c])
</span><a href="../../base/src/GHC.List.html#unzip3"><span class="hs-identifier hs-var">unzip3</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, UsageDetails, [CoreBndr])]
</span><a href="#local-6989586621680866311"><span class="hs-identifier hs-var">triples</span></a></span><span>
</span><span id="line-2855"></span><span>
</span><span id="line-2856"></span><span>     </span><span class="hs-comment">-- 1. Determine join-point-hood of whole group, as determined by</span><span>
</span><span id="line-2857"></span><span>     </span><span class="hs-comment">--    the *unadjusted* usage details</span><span>
</span><span id="line-2858"></span><span>     </span><span id="local-6989586621680866306"><span class="annot"><span class="annottext">unadj_uds :: UsageDetails
</span><a href="#local-6989586621680866306"><span class="hs-identifier hs-var hs-var">unadj_uds</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [UsageDetails] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-var">andUDs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866312"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866309"><span class="hs-identifier hs-var">rhs_udss</span></a></span><span>
</span><span id="line-2859"></span><span>     </span><span id="local-6989586621680866305"><span class="annot"><span class="annottext">will_be_joins :: Bool
</span><a href="#local-6989586621680866305"><span class="hs-identifier hs-var hs-var">will_be_joins</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; UsageDetails -&gt; [CoreBndr] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#decideJoinPointHood"><span class="hs-identifier hs-var">decideJoinPointHood</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680866313"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866306"><span class="hs-identifier hs-var">unadj_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866310"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2860"></span><span>
</span><span id="line-2861"></span><span>     </span><span class="hs-comment">-- 2. Adjust usage details of each RHS, taking into account the</span><span>
</span><span id="line-2862"></span><span>     </span><span class="hs-comment">--    join-point-hood decision</span><span>
</span><span id="line-2863"></span><span>     </span><span id="local-6989586621680866304"><span class="annot"><span class="annottext">rhs_udss' :: [UsageDetails]
</span><a href="#local-6989586621680866304"><span class="hs-identifier hs-var hs-var">rhs_udss'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreBndr, UsageDetails, [CoreBndr]) -&gt; UsageDetails)
-&gt; [(CoreBndr, UsageDetails, [CoreBndr])] -&gt; [UsageDetails]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, UsageDetails, [CoreBndr]) -&gt; UsageDetails
</span><a href="#local-6989586621680866303"><span class="hs-identifier hs-var">adjust</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, UsageDetails, [CoreBndr])]
</span><a href="#local-6989586621680866311"><span class="hs-identifier hs-var">triples</span></a></span><span>
</span><span id="line-2864"></span><span>     </span><span id="local-6989586621680866303"><span class="annot"><span class="annottext">adjust :: (CoreBndr, UsageDetails, [CoreBndr]) -&gt; UsageDetails
</span><a href="#local-6989586621680866303"><span class="hs-identifier hs-var hs-var">adjust</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680866302"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866302"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866301"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866301"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680866300"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866300"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2865"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
-&gt; RecFlag -&gt; [CoreBndr] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#adjustRhsUsage"><span class="hs-identifier hs-var">adjustRhsUsage</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680866299"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866300"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866301"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span>
</span><span id="line-2866"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-2867"></span><span>         </span><span class="hs-comment">-- Can't use willBeJoinId_maybe here because we haven't tagged the</span><span>
</span><span id="line-2868"></span><span>         </span><span class="hs-comment">-- binder yet (the tag depends on these adjustments!)</span><span>
</span><span id="line-2869"></span><span>         </span><span id="local-6989586621680866299"><span class="annot"><span class="annottext">mb_join_arity :: Maybe JoinArity
</span><a href="#local-6989586621680866299"><span class="hs-identifier hs-var hs-var">mb_join_arity</span></a></span></span><span>
</span><span id="line-2870"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866305"><span class="hs-identifier hs-var">will_be_joins</span></a></span><span>
</span><span id="line-2871"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680866297"><span class="annot"><span class="annottext">occ :: OccInfo
</span><a href="#local-6989586621680866297"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var">lookupDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866306"><span class="hs-identifier hs-var">unadj_uds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866302"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2872"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-type">AlwaysTailCalled</span></a></span><span> </span><span id="local-6989586621680866296"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866296"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866297"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-2873"></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Maybe JoinArity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866296"><span class="hs-identifier hs-var">arity</span></a></span><span>
</span><span id="line-2874"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2875"></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-identifier">will_be_joins</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Should be AlwaysTailCalled if</span><span>
</span><span id="line-2876"></span><span>             </span><span class="annot"><span class="annottext">Maybe JoinArity
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                   </span><span class="hs-comment">-- we are making join points!</span><span>
</span><span id="line-2877"></span><span>
</span><span id="line-2878"></span><span>     </span><span class="hs-comment">-- 3. Compute final usage details from adjusted RHS details</span><span>
</span><span id="line-2879"></span><span>     </span><span id="local-6989586621680866294"><span class="annot"><span class="annottext">adj_uds :: UsageDetails
</span><a href="#local-6989586621680866294"><span class="hs-identifier hs-var hs-var">adj_uds</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UsageDetails -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [UsageDetails] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#andUDs"><span class="hs-identifier hs-var">andUDs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866312"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[UsageDetails]
</span><a href="#local-6989586621680866304"><span class="hs-identifier hs-var">rhs_udss'</span></a></span><span>
</span><span id="line-2880"></span><span>
</span><span id="line-2881"></span><span>     </span><span class="hs-comment">-- 4. Tag each binder with its adjusted details</span><span>
</span><span id="line-2882"></span><span>     </span><span id="local-6989586621680866293"><span class="annot"><span class="annottext">bndrs' :: [CoreBndr]
</span><a href="#local-6989586621680866293"><span class="hs-identifier hs-var hs-var">bndrs'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#setBinderOcc"><span class="hs-identifier hs-var">setBinderOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var">lookupDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866294"><span class="hs-identifier hs-var">adj_uds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866292"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866292"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2883"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680866292"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866292"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866310"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-2884"></span><span>
</span><span id="line-2885"></span><span>     </span><span class="hs-comment">-- 5. Drop the binders from the adjusted details and return</span><span>
</span><span id="line-2886"></span><span>     </span><span id="local-6989586621680866291"><span class="annot"><span class="annottext">usage' :: UsageDetails
</span><a href="#local-6989586621680866291"><span class="hs-identifier hs-var hs-var">usage'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866294"><span class="hs-identifier hs-var">adj_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [CoreBndr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.OccurAnal.html#delDetailsList"><span class="hs-operator hs-var">`delDetailsList`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866310"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2887"></span><span>   </span><span class="hs-keyword">in</span><span>
</span><span id="line-2888"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866291"><span class="hs-identifier hs-var">usage'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866293"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2889"></span><span>
</span><span id="line-2890"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#setBinderOcc"><span class="hs-identifier hs-type">setBinderOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span>
</span><span id="line-2891"></span><span id="setBinderOcc"><span class="annot"><span class="annottext">setBinderOcc :: OccInfo -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.OccurAnal.html#setBinderOcc"><span class="hs-identifier hs-var hs-var">setBinderOcc</span></a></span></span><span> </span><span id="local-6989586621680866290"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866290"><span class="hs-identifier hs-var">occ_info</span></a></span></span><span> </span><span id="local-6989586621680866289"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2892"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2893"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isManyOccs"><span class="hs-identifier hs-var">isManyOccs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2894"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2895"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdOccInfo"><span class="hs-identifier hs-var">setIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#noOccInfo"><span class="hs-identifier hs-var">noOccInfo</span></a></span><span>
</span><span id="line-2896"></span><span>            </span><span class="hs-comment">-- Don't use local usage info for visible-elsewhere things</span><span>
</span><span id="line-2897"></span><span>            </span><span class="hs-comment">-- BUT *do* erase any IAmALoopBreaker annotation, because we're</span><span>
</span><span id="line-2898"></span><span>            </span><span class="hs-comment">-- about to re-generate it and it shouldn't be &quot;sticky&quot;</span><span>
</span><span id="line-2899"></span><span>
</span><span id="line-2900"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdOccInfo"><span class="hs-identifier hs-var">setIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866289"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866290"><span class="hs-identifier hs-var">occ_info</span></a></span><span>
</span><span id="line-2901"></span><span>
</span><span id="line-2902"></span><span class="hs-comment">-- | Decide whether some bindings should be made into join points or not.</span><span>
</span><span id="line-2903"></span><span class="hs-comment">-- Returns `False` if they can't be join points. Note that it's an</span><span>
</span><span id="line-2904"></span><span class="hs-comment">-- all-or-nothing decision, as if multiple binders are given, they're</span><span>
</span><span id="line-2905"></span><span class="hs-comment">-- assumed to be mutually recursive.</span><span>
</span><span id="line-2906"></span><span class="hs-comment">--</span><span>
</span><span id="line-2907"></span><span class="hs-comment">-- It must, however, be a final decision. If we say &quot;True&quot; for 'f',</span><span>
</span><span id="line-2908"></span><span class="hs-comment">-- and then subsequently decide /not/ make 'f' into a join point, then</span><span>
</span><span id="line-2909"></span><span class="hs-comment">-- the decision about another binding 'g' might be invalidated if (say)</span><span>
</span><span id="line-2910"></span><span class="hs-comment">-- 'f' tail-calls 'g'.</span><span>
</span><span id="line-2911"></span><span class="hs-comment">--</span><span>
</span><span id="line-2912"></span><span class="hs-comment">-- See Note [Invariants on join points] in &quot;GHC.Core&quot;.</span><span>
</span><span id="line-2913"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#decideJoinPointHood"><span class="hs-identifier hs-type">decideJoinPointHood</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2914"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2915"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2916"></span><span id="decideJoinPointHood"><span class="annot"><span class="annottext">decideJoinPointHood :: TopLevelFlag -&gt; UsageDetails -&gt; [CoreBndr] -&gt; Bool
</span><a href="GHC.Core.Opt.OccurAnal.html#decideJoinPointHood"><span class="hs-identifier hs-var hs-var">decideJoinPointHood</span></a></span></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-2917"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2918"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#decideJoinPointHood"><span class="hs-identifier hs-var">decideJoinPointHood</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span> </span><span id="local-6989586621680866287"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866287"><span class="hs-identifier hs-var">usage</span></a></span></span><span> </span><span id="local-6989586621680866286"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866286"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-2919"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreBndr] -&gt; CoreBndr
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866286"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2920"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-identifier">all_ok</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;OccurAnal failed to rediscover join point(s):&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span>
</span><span id="line-2921"></span><span>                       </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">bndrs</span><span class="hs-special">)</span><span>
</span><span id="line-2922"></span><span>    </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866283"><span class="hs-identifier hs-var">all_ok</span></a></span><span>
</span><span id="line-2923"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2924"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680866283"><span class="hs-identifier hs-var">all_ok</span></a></span><span>
</span><span id="line-2925"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2926"></span><span>    </span><span class="hs-comment">-- See Note [Invariants on join points]; invariants cited by number below.</span><span>
</span><span id="line-2927"></span><span>    </span><span class="hs-comment">-- Invariant 2 is always satisfiable by the simplifier by eta expansion.</span><span>
</span><span id="line-2928"></span><span>    </span><span id="local-6989586621680866283"><span class="annot"><span class="annottext">all_ok :: Bool
</span><a href="#local-6989586621680866283"><span class="hs-identifier hs-var hs-var">all_ok</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- Invariant 3: Either all are join points or none are</span><span>
</span><span id="line-2929"></span><span>             </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="#local-6989586621680866281"><span class="hs-identifier hs-var">ok</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680866286"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2930"></span><span>
</span><span id="line-2931"></span><span>    </span><span id="local-6989586621680866281"><span class="annot"><span class="annottext">ok :: CoreBndr -&gt; Bool
</span><a href="#local-6989586621680866281"><span class="hs-identifier hs-var hs-var">ok</span></a></span></span><span> </span><span id="local-6989586621680866279"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866279"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2932"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="hs-comment">-- Invariant 1: Only tail calls, all same join arity</span><span>
</span><span id="line-2933"></span><span>        </span><span class="annot"><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-type">AlwaysTailCalled</span></a></span><span> </span><span id="local-6989586621680866278"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866278"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails -&gt; CoreBndr -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#lookupDetails"><span class="hs-identifier hs-var">lookupDetails</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680866287"><span class="hs-identifier hs-var">usage</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866279"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2934"></span><span>
</span><span id="line-2935"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- Invariant 1 as applied to LHSes of rules</span><span>
</span><span id="line-2936"></span><span>        </span><span class="annot"><span class="annottext">(CoreRule -&gt; Bool) -&gt; [CoreRule] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; CoreRule -&gt; Bool
</span><a href="#local-6989586621680866277"><span class="hs-identifier hs-var">ok_rule</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866278"><span class="hs-identifier hs-var">arity</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; [CoreRule]
</span><a href="GHC.Types.Id.html#idCoreRules"><span class="hs-identifier hs-var">idCoreRules</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866279"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2937"></span><span>
</span><span id="line-2938"></span><span>        </span><span class="hs-comment">-- Invariant 2a: stable unfoldings</span><span>
</span><span id="line-2939"></span><span>        </span><span class="hs-comment">-- See Note [Join points and INLINE pragmas]</span><span>
</span><span id="line-2940"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Unfolding -&gt; Bool
</span><a href="#local-6989586621680866276"><span class="hs-identifier hs-var">ok_unfolding</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866278"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866279"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2941"></span><span>
</span><span id="line-2942"></span><span>        </span><span class="hs-comment">-- Invariant 4: Satisfies polymorphism rule</span><span>
</span><span id="line-2943"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isValidJoinPointType"><span class="hs-identifier hs-var">isValidJoinPointType</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866278"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866279"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2944"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2945"></span><span>
</span><span id="line-2946"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2947"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2948"></span><span>
</span><span id="line-2949"></span><span>    </span><span id="local-6989586621680866277"><span class="annot"><span class="annottext">ok_rule :: JoinArity -&gt; CoreRule -&gt; Bool
</span><a href="#local-6989586621680866277"><span class="hs-identifier hs-var hs-var">ok_rule</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><a href="GHC.Core.html#BuiltinRule"><span class="hs-identifier hs-type">BuiltinRule</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-comment">-- only possible with plugin shenanigans</span><span>
</span><span id="line-2950"></span><span>    </span><span class="annot"><a href="#local-6989586621680866277"><span class="hs-identifier hs-var">ok_rule</span></a></span><span> </span><span id="local-6989586621680866272"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866272"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rule"><span class="hs-identifier hs-type">Rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_args :: CoreRule -&gt; [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866271"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866271"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2951"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680866271"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity -&gt; Bool
forall a. [a] -&gt; JoinArity -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthIs"><span class="hs-operator hs-var">`lengthIs`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866272"><span class="hs-identifier hs-var">join_arity</span></a></span><span>
</span><span id="line-2952"></span><span>        </span><span class="hs-comment">-- Invariant 1 as applied to LHSes of rules</span><span>
</span><span id="line-2953"></span><span>
</span><span id="line-2954"></span><span>    </span><span class="hs-comment">-- ok_unfolding returns False if we should /not/ convert a non-join-id</span><span>
</span><span id="line-2955"></span><span>    </span><span class="hs-comment">-- into a join-id, even though it is AlwaysTailCalled</span><span>
</span><span id="line-2956"></span><span>    </span><span id="local-6989586621680866276"><span class="annot"><span class="annottext">ok_unfolding :: JoinArity -&gt; Unfolding -&gt; Bool
</span><a href="#local-6989586621680866276"><span class="hs-identifier hs-var hs-var">ok_unfolding</span></a></span></span><span> </span><span id="local-6989586621680866269"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866269"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866268"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866268"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: Unfolding -&gt; CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866267"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866267"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2957"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680866268"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866269"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier hs-var">joinRhsArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680866267"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2958"></span><span>    </span><span class="annot"><a href="#local-6989586621680866276"><span class="hs-identifier hs-var">ok_unfolding</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2959"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2960"></span><span>    </span><span class="annot"><a href="#local-6989586621680866276"><span class="hs-identifier hs-var">ok_unfolding</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-2961"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2962"></span><span>
</span><span id="line-2963"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#willBeJoinId_maybe"><span class="hs-identifier hs-type">willBeJoinId_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>
</span><span id="line-2964"></span><span id="willBeJoinId_maybe"><span class="annot"><span class="annottext">willBeJoinId_maybe :: CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Core.Opt.OccurAnal.html#willBeJoinId_maybe"><span class="hs-identifier hs-var hs-var">willBeJoinId_maybe</span></a></span></span><span> </span><span id="local-6989586621680866266"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866266"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-2965"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866266"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2966"></span><span>      </span><span class="annot"><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-type">AlwaysTailCalled</span></a></span><span> </span><span id="local-6989586621680866265"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866265"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Maybe JoinArity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866265"><span class="hs-identifier hs-var">arity</span></a></span><span>
</span><span id="line-2967"></span><span>      </span><span class="annot"><span class="annottext">TailCallInfo
</span><span class="hs-identifier">_</span></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680866266"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2968"></span><span>
</span><span id="line-2969"></span><span>
</span><span id="line-2970"></span><span class="hs-comment">{- Note [Join points and INLINE pragmas]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   f x = let g = \x. not  -- Arity 1
             {-# INLINE g #-}
         in case x of
              A -&gt; g True True
              B -&gt; g True False
              C -&gt; blah2

Here 'g' is always tail-called applied to 2 args, but the stable
unfolding captured by the INLINE pragma has arity 1.  If we try to
convert g to be a join point, its unfolding will still have arity 1
(since it is stable, and we don't meddle with stable unfoldings), and
Lint will complain (see Note [Invariants on join points], (2a), in
GHC.Core.  #13413.

Moreover, since g is going to be inlined anyway, there is no benefit
from making it a join point.

If it is recursive, and uselessly marked INLINE, this will stop us
making it a join point, which is annoying.  But occasionally
(notably in class methods; see Note [Instances and loop breakers] in
GHC.Tc.TyCl.Instance) we mark recursive things as INLINE but the recursion
unravels; so ignoring INLINE pragmas on recursive things isn't good
either.

See Invariant 2a of Note [Invariants on join points] in GHC.Core


************************************************************************
*                                                                      *
\subsection{Operations over OccInfo}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-3006"></span><span>
</span><span id="line-3007"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markMany"><span class="hs-identifier hs-type">markMany</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markInsideLam"><span class="hs-identifier hs-type">markInsideLam</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-type">markNonTail</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span>
</span><span id="line-3008"></span><span>
</span><span id="line-3009"></span><span id="markMany"><span class="annot"><span class="annottext">markMany :: OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markMany"><span class="hs-identifier hs-var hs-var">markMany</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#IAmDead"><span class="hs-identifier hs-var">IAmDead</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#IAmDead"><span class="hs-identifier hs-var">IAmDead</span></a></span><span>
</span><span id="line-3010"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markMany"><span class="hs-identifier hs-var">markMany</span></a></span><span> </span><span id="local-6989586621680866264"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866264"><span class="hs-identifier hs-var">occ</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ManyOccs :: TailCallInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#ManyOccs"><span class="hs-identifier hs-type">ManyOccs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var hs-var">occ_tail</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866264"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3011"></span><span>
</span><span id="line-3012"></span><span id="markInsideLam"><span class="annot"><span class="annottext">markInsideLam :: OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markInsideLam"><span class="hs-identifier hs-var hs-var">markInsideLam</span></a></span></span><span> </span><span id="local-6989586621680866262"><span class="annot"><span class="annottext">occ :: OccInfo
</span><a href="#local-6989586621680866262"><span class="hs-identifier hs-var">occ</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866262"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InsideLam
</span><a href="GHC.Types.Basic.html#IsInsideLam"><span class="hs-identifier hs-var">IsInsideLam</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3013"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markInsideLam"><span class="hs-identifier hs-var">markInsideLam</span></a></span><span> </span><span id="local-6989586621680866260"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866260"><span class="hs-identifier hs-var">occ</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866260"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-3014"></span><span>
</span><span id="line-3015"></span><span id="markNonTail"><span class="annot"><span class="annottext">markNonTail :: OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-var hs-var">markNonTail</span></a></span></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#IAmDead"><span class="hs-identifier hs-var">IAmDead</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="GHC.Types.Basic.html#IAmDead"><span class="hs-identifier hs-var">IAmDead</span></a></span><span>
</span><span id="line-3016"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#markNonTail"><span class="hs-identifier hs-var">markNonTail</span></a></span><span> </span><span id="local-6989586621680866259"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866259"><span class="hs-identifier hs-var">occ</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866259"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="GHC.Types.Basic.html#NoTailCallInfo"><span class="hs-identifier hs-var">NoTailCallInfo</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3017"></span><span>
</span><span id="line-3018"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#addOccInfo"><span class="hs-identifier hs-type">addOccInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#orOccInfo"><span class="hs-identifier hs-type">orOccInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OccInfo"><span class="hs-identifier hs-type">OccInfo</span></a></span><span>
</span><span id="line-3019"></span><span>
</span><span id="line-3020"></span><span id="addOccInfo"><span class="annot"><span class="annottext">addOccInfo :: OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#addOccInfo"><span class="hs-identifier hs-var hs-var">addOccInfo</span></a></span></span><span> </span><span id="local-6989586621680866257"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866257"><span class="hs-identifier hs-var">a1</span></a></span></span><span> </span><span id="local-6989586621680866256"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866256"><span class="hs-identifier hs-var">a2</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isDeadOcc</span><span> </span><span class="hs-identifier">a1</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">isDeadOcc</span><span> </span><span class="hs-identifier">a2</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-3021"></span><span>                    </span><span class="annot"><span class="annottext">ManyOccs :: TailCallInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#ManyOccs"><span class="hs-identifier hs-type">ManyOccs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866257"><span class="hs-identifier hs-var">a1</span></a></span><span> </span><span class="annot"><span class="annottext">TailCallInfo -&gt; TailCallInfo -&gt; TailCallInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-operator hs-var">`andTailCallInfo`</span></a></span><span>
</span><span id="line-3022"></span><span>                                          </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866256"><span class="hs-identifier hs-var">a2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3023"></span><span>                                </span><span class="hs-comment">-- Both branches are at least One</span><span>
</span><span id="line-3024"></span><span>                                </span><span class="hs-comment">-- (Argument is never IAmDead)</span><span>
</span><span id="line-3025"></span><span>
</span><span id="line-3026"></span><span class="hs-comment">-- (orOccInfo orig new) is used</span><span>
</span><span id="line-3027"></span><span class="hs-comment">-- when combining occurrence info from branches of a case</span><span>
</span><span id="line-3028"></span><span>
</span><span id="line-3029"></span><span id="orOccInfo"><span class="annot"><span class="annottext">orOccInfo :: OccInfo -&gt; OccInfo -&gt; OccInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#orOccInfo"><span class="hs-identifier hs-var hs-var">orOccInfo</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: OccInfo -&gt; InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866253"><span class="annot"><span class="annottext">InsideLam
</span><a href="#local-6989586621680866253"><span class="hs-identifier hs-var">in_lam1</span></a></span></span><span>
</span><span id="line-3030"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_n_br :: OccInfo -&gt; JoinArity
</span><a href="GHC.Types.Basic.html#occ_n_br"><span class="hs-identifier hs-var">occ_n_br</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866252"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866252"><span class="hs-identifier hs-var">nbr1</span></a></span></span><span>
</span><span id="line-3031"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_int_cxt :: OccInfo -&gt; InterestingCxt
</span><a href="GHC.Types.Basic.html#occ_int_cxt"><span class="hs-identifier hs-var">occ_int_cxt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866251"><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866251"><span class="hs-identifier hs-var">int_cxt1</span></a></span></span><span>
</span><span id="line-3032"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_tail :: OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866250"><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680866250"><span class="hs-identifier hs-var">tail1</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-3033"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: OccInfo -&gt; InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866249"><span class="annot"><span class="annottext">InsideLam
</span><a href="#local-6989586621680866249"><span class="hs-identifier hs-var">in_lam2</span></a></span></span><span>
</span><span id="line-3034"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_n_br :: OccInfo -&gt; JoinArity
</span><a href="GHC.Types.Basic.html#occ_n_br"><span class="hs-identifier hs-var">occ_n_br</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866248"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866248"><span class="hs-identifier hs-var">nbr2</span></a></span></span><span>
</span><span id="line-3035"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_int_cxt :: OccInfo -&gt; InterestingCxt
</span><a href="GHC.Types.Basic.html#occ_int_cxt"><span class="hs-identifier hs-var">occ_int_cxt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866247"><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866247"><span class="hs-identifier hs-var">int_cxt2</span></a></span></span><span>
</span><span id="line-3036"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_tail :: OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680866246"><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680866246"><span class="hs-identifier hs-var">tail2</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-3037"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OneOcc :: InsideLam -&gt; JoinArity -&gt; InterestingCxt -&gt; TailCallInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#OneOcc"><span class="hs-identifier hs-type">OneOcc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_n_br :: JoinArity
</span><a href="GHC.Types.Basic.html#occ_n_br"><span class="hs-identifier hs-var">occ_n_br</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866252"><span class="hs-identifier hs-var">nbr1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866248"><span class="hs-identifier hs-var">nbr2</span></a></span><span>
</span><span id="line-3038"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_in_lam :: InsideLam
</span><a href="GHC.Types.Basic.html#occ_in_lam"><span class="hs-identifier hs-var">occ_in_lam</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InsideLam
</span><a href="#local-6989586621680866253"><span class="hs-identifier hs-var">in_lam1</span></a></span><span> </span><span class="annot"><span class="annottext">InsideLam -&gt; InsideLam -&gt; InsideLam
forall a. Monoid a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-operator hs-var">`mappend`</span></a></span><span> </span><span class="annot"><span class="annottext">InsideLam
</span><a href="#local-6989586621680866249"><span class="hs-identifier hs-var">in_lam2</span></a></span><span>
</span><span id="line-3039"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_int_cxt :: InterestingCxt
</span><a href="GHC.Types.Basic.html#occ_int_cxt"><span class="hs-identifier hs-var">occ_int_cxt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866251"><span class="hs-identifier hs-var">int_cxt1</span></a></span><span> </span><span class="annot"><span class="annottext">InterestingCxt -&gt; InterestingCxt -&gt; InterestingCxt
forall a. Monoid a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-operator hs-var">`mappend`</span></a></span><span> </span><span class="annot"><span class="annottext">InterestingCxt
</span><a href="#local-6989586621680866247"><span class="hs-identifier hs-var">int_cxt2</span></a></span><span>
</span><span id="line-3040"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680866250"><span class="hs-identifier hs-var">tail1</span></a></span><span> </span><span class="annot"><span class="annottext">TailCallInfo -&gt; TailCallInfo -&gt; TailCallInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-operator hs-var">`andTailCallInfo`</span></a></span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680866246"><span class="hs-identifier hs-var">tail2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3041"></span><span>
</span><span id="line-3042"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#orOccInfo"><span class="hs-identifier hs-var">orOccInfo</span></a></span><span> </span><span id="local-6989586621680866245"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866245"><span class="hs-identifier hs-var">a1</span></a></span></span><span> </span><span id="local-6989586621680866244"><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866244"><span class="hs-identifier hs-var">a2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isDeadOcc</span><span> </span><span class="hs-identifier">a1</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">isDeadOcc</span><span> </span><span class="hs-identifier">a2</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-3043"></span><span>                  </span><span class="annot"><span class="annottext">ManyOccs :: TailCallInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#ManyOccs"><span class="hs-identifier hs-type">ManyOccs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">occ_tail :: TailCallInfo
</span><a href="GHC.Types.Basic.html#occ_tail"><span class="hs-identifier hs-var">occ_tail</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866245"><span class="hs-identifier hs-var">a1</span></a></span><span> </span><span class="annot"><span class="annottext">TailCallInfo -&gt; TailCallInfo -&gt; TailCallInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-operator hs-var">`andTailCallInfo`</span></a></span><span>
</span><span id="line-3044"></span><span>                                        </span><span class="annot"><span class="annottext">OccInfo -&gt; TailCallInfo
</span><a href="GHC.Types.Basic.html#tailCallInfo"><span class="hs-identifier hs-var">tailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621680866244"><span class="hs-identifier hs-var">a2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-3045"></span><span>
</span><span id="line-3046"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-identifier hs-type">andTailCallInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TailCallInfo"><span class="hs-identifier hs-type">TailCallInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TailCallInfo"><span class="hs-identifier hs-type">TailCallInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TailCallInfo"><span class="hs-identifier hs-type">TailCallInfo</span></a></span><span>
</span><span id="line-3047"></span><span id="andTailCallInfo"><span class="annot"><span class="annottext">andTailCallInfo :: TailCallInfo -&gt; TailCallInfo -&gt; TailCallInfo
</span><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-identifier hs-var hs-var">andTailCallInfo</span></a></span></span><span> </span><span id="local-6989586621680866243"><span class="annot"><span class="annottext">info :: TailCallInfo
</span><a href="#local-6989586621680866243"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-type">AlwaysTailCalled</span></a></span><span> </span><span id="local-6989586621680866242"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866242"><span class="hs-identifier hs-var">arity1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#AlwaysTailCalled"><span class="hs-identifier hs-type">AlwaysTailCalled</span></a></span><span> </span><span id="local-6989586621680866241"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866241"><span class="hs-identifier hs-var">arity2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-3048"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866242"><span class="hs-identifier hs-var">arity1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680866241"><span class="hs-identifier hs-var">arity2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="#local-6989586621680866243"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-3049"></span><span class="annot"><a href="GHC.Core.Opt.OccurAnal.html#andTailCallInfo"><span class="hs-identifier hs-var">andTailCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TailCallInfo
</span><a href="GHC.Types.Basic.html#NoTailCallInfo"><span class="hs-identifier hs-var">NoTailCallInfo</span></a></span><span>
</span><span id="line-3050"></span></pre></body></html>